Home » RDBMS Server » Server Administration » Syntax question SEQUENCES
Syntax question SEQUENCES [message #370718] Sat, 22 January 2000 05:01 Go to next message
Laert
Messages: 20
Registered: January 2000
Junior Member
Hi!

Can someone help me?
How can I in before trigger correct write something like this

new.ID := sequence.NEXTVAL;

Thanx in advance.
Re: Syntax question SEQUENCES [message #370723 is a reply to message #370718] Sat, 22 January 2000 10:57 Go to previous messageGo to next message
Paul
Messages: 164
Registered: April 1999
Senior Member
Laert,
Try this, assuming you don't already have one
you will first need to create a sequence as in:
CREATE SEQUENCE my_sequence;

then you can create your trigger like this:

CREATE TRIGGER my_trigger
BEFORE INSERT ON my_table
FOR EACH ROW
BEGIN
SELECT my_sequence.nextval
INTO :NEW.ID
FROM dual;
END;

Hope it helps,
Paul
Re: Syntax question SEQUENCES [message #370727 is a reply to message #370723] Mon, 24 January 2000 03:02 Go to previous message
Laert
Messages: 20
Registered: January 2000
Junior Member
Thank You very much. It helps.
Previous Topic: help on select count statement
Next Topic: SQL "to_integer" conversion
Goto Forum:
  


Current Time: Tue Oct 20 10:17:15 CDT 2020