Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: declare variable in trigger
harun.bolat_at_netsim.net wrote:
> thanks,
>
> I have posted trigger only to simplify an example.
>
> as example firebird trigger like this.
> variable of CARI_ISLEM_NO same as field name.
No it is not!
:CARI_BAGLANTI_NO2 != CARI_BAGLANTI_NO2
If you can place a ":" in front of every occurance of the variable, why
not a "v_"?
Firebird is taking the "easy way out" of name resolution. It is in
violation of the SQL standard.
I find it interesting that in some places the ':' appears to be needed
while in others it is not. What are the rules?
E.g.: "IF(FIRMA_NO1 <> FIRMA_NO2) THEN", and "DECLARE VARIABLE FIRMA_NO1
INTEGER" no ":" here.
I understand that Oracle and Firebird are different, but they have
different syntax to begin with. By no means is the variable resolution
any better that PL/SQLs. In fact PL/SQL appears to be closer to ANSI
SQL/PSM with that respect.
SQL name resolution defines that all identifiers are resolved from the
inside out. That is you start with the inner most object (e.g. a scalar
subquery table reference), then work yourself outside to finally the
outermost table references. If the name cannot be resolved it must be
either (in order):
1. A local variable 2. A trigger variable/routine parameter 3. A global variable
Any conflicts can be overcome with labels/schema names (such as NEW in case of a trigger). Just like in real life family names are used if you refer to John and it's not obvious you mean the John standing right next to you.
Cheers
Serge
-- Serge Rielau DB2 Solutions Development IBM Toronto Lab WAIUG Conference http://www.iiug.org/waiug/present/Forum2006/Forum2006.htmlReceived on Fri Dec 29 2006 - 06:14:26 CST