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: Oracle Triggers variable

Re: Oracle Triggers variable

From: sybrandb <sybrandb_at_gmail.com>
Date: 8 May 2007 01:26:26 -0700
Message-ID: <1178612786.204501.37200@w5g2000hsg.googlegroups.com>


On May 8, 9:53 am, Kovu <kovut..._at_gmail.com> wrote:
> Hello, I'm writing this post to ask you about If can I get a variable
> of trigger to my code in asp.net 2.0?.
>
> I have this code in my trigger:
>
> create or replace TRIGGER CORRELATIVO_EXPEDIENTE BEFORE INSERT ON
> EXP REFERENCING NEW AS New FOR EACH ROW DECLARE contador NUMBER;
> BEGIN contador:=0; SELECT NVL(MAX(id_exp),0) +1 INTO contador FROM
> EXP; :NEW.id_exp:=contador; END;
>
> I want to get "contador".
>
> Thanks for all.

You would set up a package with a variable. In the package is 1 procedure to set the variable (which is to be called by the trigger)
and one function to retrieve the variable. You do realize your current approach (select max(id) from <table on which is the trigger>) won't work, and what's more is unscalable? The full table scan on exp is going to take more an more time. Why don't you use a sequence?

--
Sybrand Bakker
Senior Oracle DBA
Received on Tue May 08 2007 - 03:26:26 CDT

Original text of this message

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