Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> increment-trigger
Hi there,
I try to do an auto_increment-funtion with a trigger:
I have a sequence:
Create or replace sequence KI_SEQ increment by1 start with 1 cache 2;
A table:
Create table KIDS(
KI_ID NUMBER(5) PRIMARY KEY NOT NULL,
NAME VARCHAR(200)
....etc);
And the Trigger
Create or replace Trigger KI_PK before insert on KIDS for each row
Begin
Select KI_SEQ.NEXTVAL into :NEW.KI_ID from DUAL;
End;
/
done.
When I start the query:
Insert into KIDS VALUES ('', 'Anything'.....)
follows this Warning:
OCIStmtExecute: ORA-04098: trigger 'MY_OR.KI_PK' is invalid and failed
re-validation
and the insert doesnīt happen.
I donīt know Oracle very much, but does anybody knows trigger like this? And knows where my error is?
Thx
Marius
Received on Sat Aug 17 2002 - 08:21:20 CDT
![]() |
![]() |