Message-Id: <25929.337868@fatcity.com> From: Andreas.Haunschmidt@voestalpine.com Date: Tue, 15 Jul 2003 20:09:07 +0200 Subject: RE: oracle listener ("auto increment value" for PK) Sorry I meant "Hi Martin" -----Original Message----- From: Haunschmidt Andreas VAIG.TWI Sent: Tuesday, July 15, 2003 8:59 PM To: Multiple recipients of list ORACLE-L Subject: RE: oracle listener ("auto increment value" for PK) Hi Markus! Here's a recipe that might help you (assuming your table is called "MYTABLE": 1. create a sequence: CREATE SEQUENCE MYTABLE_Sequence start with 1 increment by 1 nocycle nocache; 2. create an insert trigger CREATE OR REPLACE TRIGGER MYTABLE_Insert_Trigger BEFORE INSERT ON MYTABLE FOR EACH ROW DECLARE n PLS_INTEGER; BEGIN -- get the next "auto increment value" SELECT MYTABLE_Sequence.NEXTVAL INTO n FROM DUAL; -- assign the value to the ID of the row that is being inserted