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

Home -> Community -> Usenet -> c.d.o.tools -> Re: first trigger, how do I incremement a value?

Re: first trigger, how do I incremement a value?

From: RHC <rclarence_at_juno.com>
Date: Mon, 05 Mar 2001 23:30:03 -0000
Message-ID: <ta88broimdov5f@corp.supernews.com>

If you are going to use this method in a multi user environment you really should lock the table first via

select <fieldname>+1 from NMBRHOLDINGS
for update of <fieldname>

HTH RHC Ted Knijff wrote:
>
>
> Try :
> CREATE OR REPLACE TRIGGER SET_HOLDNR BEFORE
> INSERT ON HOLDING FOR EACH ROW
> BEGIN
> UPDATE NMBRHOLDINGS SET <fieldname> = <fieldname> + 1;
> END;
>
> I assume that NMBRHOLDINGS is a table, fieldname a field NUMBER type.
>
> And read a manual or the PL/SQL help.
>
> Hth,
>
> Ted
> On Sat, 03 Mar 2001 19:19:59 GMT, "MadG" <patrick4133_at_hotmail.com>
> wrote:
>
> >Heya!
> >
> >It's my first trigger and I need a little help.
> >
> >I have to Create a trigger on the HOLDING table that will add 1 to the
> >appropriate value in NMBRHOLDINGS when a row is inserted into the
 HOLDING
> >table.
> >
> >But I don't know how to go about actually adding 1.
> >
> >All I have seen or can find is comparrisons, nothing with a +,
> >
> >can someone help me out or post a url that can help?
> >
> >Thanks in advance.
> >
> >Patrick.
> >
> >
>
> EMail: knijff_at_bigfoot.com

--
Posted via CNET Help.com
http://www.help.com/
Received on Mon Mar 05 2001 - 17:30:03 CST

Original text of this message

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