>You don't need to "reproduce SQL server's autoincrement feature", as Oracle
>already has its own Sequence functionality, CREATE SEQUENCE. And you don't
>need a trigger, Oracle sequences work on normal insert statements.

Just creating a sequence will not 'auto-increment' an integer column when 
new rows are inserted. I have had to reproduce/emulate SQL server's 
auto-increment feature a number of times when moving apps from SQL Server 
to Oracle. If you want the same SQL code embedded in the CFML to work on 
both DBMSs, what other way is there to achieve this without using a 
combination of sequence and trigger?


>Much simpler...

depends on what your requirements are


Mark




>Ben
>
>-----Original Message-----
>From: Mark Woods [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, April 24, 2001 10:42 AM
>To: CF-Talk
>Subject: Re: autonumbering in oracle
>
>
>standard way is to create a sequence and then use a trigger when inserting
>a row into the table, rather than explain any further, here's some code...
>
>/* dummy table */
>CREATE TABLE test (
>          ID integer NOT NULL ,
>          sometext varchar2(50) NOT NULL ,
>          PRIMARY KEY (ID)
>          );
>
>/* Sequence and trigger to reproduce SQL server autoincrement feature */
>CREATE SEQUENCE testID NOCACHE;
>CREATE OR REPLACE TRIGGER test_AutoID
>BEFORE INSERT ON test
>FOR EACH ROW
>BEGIN
>          SELECT testID.NextVal
>          INTO :new.ID
>          FROM dual;
>END test_AutoID;
>
>
>
>Mark
>
>
>
>
>At 05:34 PM 4/24/2001, you wrote:
> >I tried to use the download custom CF_max_id to do the autonumbering
> >for inserting a new row into a oracle database table but the custom
> >tag failed.  I am wondering if anyone knows oracle have idea how to
> >do it.  I have the first column in the table named "ContentId"
> >defined with datatype "number".  I would like to have the contentid
> >incremented by 1 for each now row inserted.  Someone works with
> >oracle please let me know how to do this.
> >
> >thanks
> >
> >
> >
> >
> >
> >--------------------------------------------------------------------------
> >Global Internet phone calls, voicemail, fax, e-mail and instant messaging.
> >Sign-up today at http://www.hotvoice.com
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to