Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How do I CREATE TRIGGER?

Re: How do I CREATE TRIGGER?

From: Xuequn Xu <xux_at_informa.bio.caltech.edu>
Date: 28 Jul 1999 15:52:28 GMT
Message-ID: <7nn8vs$5u4@gap.cco.caltech.edu>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US