Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Autoincrement functionality

Re: Autoincrement functionality

From: paul <pjohnpeter_at_qssnet.com>
Date: Wed, 2 Aug 2000 09:39:56 -0500
Message-Id: <10577.113619@fatcity.com>


hi venkatramany,
 i used only triggers for assigning key values.what is the disadvantage over that may i know in detail.
paul.j
-----Original Message-----
From: Rajagopal Venkataramany <rajagopalvr_at_excite.com> To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> Date: Tuesday, August 01, 2000 10:09 PM
Subject: Re: Autoincrement functionality

>Hi,
>
> If you use a stored procedure interface to populate the table,
> then the stored procedure can be used to get the next value from
> the sequence and set the key field accordingly, before insert can
> take place. This would be an ideal and recommended way of doing it
> and possibly avoid creating the trigger if the trigger is created
> just for assigning key values.
>
> If you have a environment, where inserts to the table may happen
> viz sqlplus or sqlloader or by other similar means where the
> insert to the table cannot be interfaced via the stored procedure,
> then for such cases, triggers make sense.
>
>** I am trying to avoid triggers here if it is used just for deciding
> the key value. If the triggers have other functionality in it
> besides this, then go ahead with the trigger logic itself.
>
>Regards
>Rajagopal Venkataramany
>
>
>
>On Tue, 01 Aug 2000 10:56:14 -0800, ORACLE-L_at_fatcity.com wrote:
>
>> Hi All,
>> I am porting a schema to Oracle from mysql that uses
>> AUTOINCREMENT to produce the primary key.
>>
>> In order to keep the application code the same I have
>> to get a number from a sequence and insert into the primary key
>> column at the database level.
>>
>> The only way I have figured out is to use a before insert trigger
>> something like:
>>
>> WARNING: THIS IS UNTESTED PSUEDO CODE
>>
>> CREATE TRIGGER AUTOINCREMENT
>> BEFORE INSERT ON TABLE TEST
>> FOR EACH ROW
>> BEGIN
>> :new.PRIMARY_KEY_ROW = TEST_NUM.nextval;
>> END;
>>
>> Has anyone done this?
>> Any other ideas?
>>
>> I am in digest mode so I will not respond until tomorrow.
>>
>> TIA
>> Dave
>>
>> --
>> Dave Morgan
>> Senior Database Administrator
>> Internet Barter Inc.
>> www.bartertrust.com
>> 408-982-8774
>> --
>> Author: Dave Morgan
>> INET: dmorgan_at_bartertrust.com
>>
>> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
>> San Diego, California -- Public Internet access / Mailing Lists
>> --------------------------------------------------------------------
>> To REMOVE yourself from this mailing list, send an E-Mail message
>> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>> the message BODY, include a line containing: UNSUB ORACLE-L
>> (or the name of mailing list you want to be removed from). You may
>> also send the HELP command for other information (like subscribing).
>
>
>Regards
>Rajagopal Venkataramany
>
>
>
>
>
>_______________________________________________________
>Say Bye to Slow Internet!
>http://www.home.com/xinbox/signup.html
>
>--
>Author: Rajagopal Venkataramany
> INET: rajagopalvr_at_excite.com
>
>Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
>San Diego, California -- Public Internet access / Mailing Lists
>--------------------------------------------------------------------
>To REMOVE yourself from this mailing list, send an E-Mail message
>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from). You may
Received on Wed Aug 02 2000 - 09:39:56 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US