Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: TRIGGER code for an auto-incrementing field?
Hi Phil,
Here's one cut-and-pasted from my working code:
create trigger tib_collectiondetails before insert
on CollectionDetails for each row
declare
integrity_error exception;
errno integer; errmsg char(200);
begin
:new.CollectionID := v_CollectionID;
mdlcpgs_at_lhn.gns.cri.nz.nospam wrote:
>
> This has to be basic, basic but as beginner, I am having trouble.
>
> I want to implement an autoincrementing field in a table, and as it can
> updated via ODBC, I need to do this with a TRIGGER.
>
> I created a sequence and tried a trigger of:
> CREATE OR REPLACE TRIGGER "RESLIB"."NEWID" BEFORE INSERT ON
> "RESLIB"."P_Well"
> BEGIN
> :new.ID := PW.NEXTVAL;
> END;
>
> However I get "NEWID" fails on revalidation when running it.
>
> Where did I go wrong?
Received on Wed Oct 29 1997 - 00:00:00 CST