Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Auto generating Sequences !!
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" - UnknownReceived on Mon Apr 10 2006 - 13:00:46 CDT
![]() |
![]() |