<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BorkWeb &#187; &#8220;auto increment&#8221;</title>
	<atom:link href="http://borkweb.com/story/tag/auto-increment/feed" rel="self" type="application/rss+xml" />
	<link>http://borkweb.com</link>
	<description>Some People Are Squirrel Handed.</description>
	<lastBuildDate>Tue, 17 Jan 2012 22:00:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Oracle&#8217;s Auto Incrementing with Sequences</title>
		<link>http://borkweb.com/story/oracles-auto-incrementing-with-sequences</link>
		<comments>http://borkweb.com/story/oracles-auto-incrementing-with-sequences#comments</comments>
		<pubDate>Fri, 17 Feb 2006 15:50:36 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA["auto increment"]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sequences]]></category>
		<category><![CDATA[sequencing]]></category>

		<guid isPermaLink="false">http://www.borkweb.com/story/oracles-auto-incrementing-with-sequences</guid>
		<description><![CDATA[My previous post, titled: &#8216;Sequence-less/Trigger-less Oracle Auto Increment&#8216; was shot out of the water by my friend and DBA, Jon Emmons. Glad to see that I can be kept in line. So I have resigned to use Oracle Sequences as a safer means for auto incrementing. But that doesn&#8217;t mean that I like it. Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>My previous post, titled: &#8216;<a href="http://www.borkweb.com/story/sequence-lesstrigger-less-oracle-auto-increment">Sequence-less/Trigger-less Oracle Auto Increment</a>&#8216; was shot out of the water by my friend and DBA, <a href="http://www.lifeaftercoffee.com/2006/02/17/how-not-to-create-auto-increment-columns-in-oracle">Jon Emmons</a>.  Glad to see that I can be kept in line.</p>
<p>So I have resigned to use Oracle Sequences as a safer means for auto incrementing.  But that doesn&#8217;t mean that I like it.  Here&#8217;s what needs to be done to implement auto_incrementing with Oracle:</p>
<p>First, create a sequence:</p>
<blockquote><p>
CREATE SEQUENCE sweet_incrementing INCREMENT BY 1 START WITH 1;
</p></blockquote>
<p>Next write your statement:</p>
<blockquote><p>
INSERT INTO table (id,name) VALUES (sweet_incrementing.NextVal,&#8217;bork&#8217;);
</p></blockquote>
<p>Now at a second glance, this statement looks much cleaner than my first attempt at subverting the system.  However, the fact that you need to create a whole new sequence for each table you wish to have an auto incrementer is pretty stupid when compared to MySQL&#8217;s plan of attack.  In MySQL you can simply mark a column as a auto_increment during table creation and you&#8217;re good to go!</p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/oracles-auto-incrementing-with-sequences/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Sequence-less/Trigger-less Oracle Auto Increment</title>
		<link>http://borkweb.com/story/sequence-lesstrigger-less-oracle-auto-increment</link>
		<comments>http://borkweb.com/story/sequence-lesstrigger-less-oracle-auto-increment#comments</comments>
		<pubDate>Thu, 16 Feb 2006 21:50:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA["auto increment"]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://www.borkweb.com/story/sequence-lesstrigger-less-oracle-auto-increment</guid>
		<description><![CDATA[Oracle sucks. Well, not totally, but it fails in a lot of places where MySQL is sexy. One little gem of an irritation is the lack of an auto_increment attribute associated with fields. Instead you have to make use of Oracle Sequences/Triggers which adds a whole layer of complexity on the creation and insertion into [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle sucks.  Well, not totally, but it fails in a lot of places where MySQL is sexy.  One little gem of an irritation is the lack of an <strong>auto_increment</strong> attribute associated with fields.  Instead you have to make use of Oracle Sequences/Triggers which adds a whole layer of complexity on the creation and insertion into a simple table.</p>
<p>I&#8217;m not quite sure on this statement&#8217;s efficiency, but here&#8217;s my solution:</p>
<blockquote><p>INSERT INTO table (id,name) (SELECT CASE WHEN MAX(id) IS NULL THEN 1 ELSE MAX(id)+1 END, &#8216;bork&#8217; FROM table);</p></blockquote>
<p>EDIT: It seems that this isn&#8217;t such a good idea, after help from my <a href="http://www.lifeaftercoffee.com/2006/02/17/how-not-to-create-auto-increment-columns-in-oracle/">friendly neighborhood DBA</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/sequence-lesstrigger-less-oracle-auto-increment/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

