Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How do I CREATE TRIGGER?
Try a better approach:
create trigger trig1 before insert on testtab2
for each row
BEGIN
:new.id = headid.nextval;
end;
/
Notice that you should use "/" after "end;" to tell sqlplus or svrmgrl to execute the PL/SQL block.
Robert Xu, Oracle DBA
Caltech, Pasadena, CA
kev (kevin.porter_at_fast.no) wrote:
: I'm trying to create a trigger to autonumber an id field.
: In svrmgrl, I wrote:
: create trigger trig1 before insert of id on testtab2
: 2> DECLARE
: 3> BEGIN
: 4> insert into testtab2 (id) values (headid.nextval);
: 5> END;
: 6> ;
: Am I going about this the right way? (headid is a sequence btw)
: From the docs, it takes a PL/SQL block. I don't know the first thing
: about PL/SQL.
: When I press return, it doesn't go back to the SVRMGR> prompt, so I
: can't even test whether the command is right. How do I get back to the
: SVRMGR> prompt, and make it recognise this as a command?
: Thanks,
: - Kev
Received on Wed Jul 28 1999 - 10:52:28 CDT
![]() |
![]() |