Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle Triggers variable
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 DBAReceived on Tue May 08 2007 - 03:26:26 CDT
![]() |
![]() |