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

Home -> Community -> Usenet -> c.d.o.server -> Re: Auto generating Sequences !!

Re: Auto generating Sequences !!

From: Brian Peasland <oracle_dba_at_nospam.peasland.net>
Date: Mon, 10 Apr 2006 18:00:46 GMT
Message-ID: <IxIq1I.3M8@igsrsparc2.er.usgs.gov>


Create the sequence outside of the trigger. If you want three different sequences, then create three sequences.

In your trigger, you can get the sequence's next value with code similar to the following:

SELECT my_sequence.NEXTVAL INTO varX FROM dual;

Once you have the value, then compute the string you want out of it:

key_val := 'S-'||LPAD(varX,8,'0');

Then set your key column to this value;

:key_colmn.new := key_val;

Since you'll have three sequences you'll probably want some IF-THEN logic in your code if this trigger will handle all three sequences on the same table.

HTH,
Brian

-- 
===================================================================

Brian Peasland
oracle_dba_at_nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Received on Mon Apr 10 2006 - 13:00:46 CDT

Original text of this message

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