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: declare variable in trigger

Re: declare variable in trigger

From: DA Morgan <damorgan_at_psoug.org>
Date: Sat, 23 Dec 2006 09:25:28 -0800
Message-ID: <1166894725.349900@bubbleator.drizzle.com>


harun.bolat_at_netsim.net wrote:
> thanks for your reply.
>
> we use firebird database and try to migrate project to oracle. All our
> database object( trigger, stored procedure) we use variable name same
> as database field name and we have no problem. using variable same as
> field name, makes code more readable.
> to migrate oracle from firebird we try to write convert program that
> takes firebird sql and produce oracle sql code.
>
> In oracle stored procedure we can use variable name same as field name
> like procedure_name.variable_name syntax. This syntax why not exists it
> trigger? in firebird P/SQL syntax never change stored procedure or
> trigger.
>
> is there any solution or we have to change variable name?
>
>
>
> What's in a namespace yazdi:

>> "zauberberg" <jwberg_at_verizon.net> argued in
>> news:1166808099.235449.67260_at_48g2000cwx.googlegroups.com...
>>> What's in a namespace wrote:
>>>> <harun.bolat_at_netsim.net> schreef in bericht
>>>> news:1166802666.166266.30290_at_48g2000cwx.googlegroups.com...
>>>>> Hi all,
>>>>>
>>>>> firstly sorry my english,
>>>>>
>>>>> how can I use variable if variable name same as table's field name?
>>>>>
>>>>> CREATE OR REPLACE TRIGGER KULLANIC_BI BEFORE INSERT ON KULLANIC
>>>>> FOR EACH ROW
>>>>> DECLARE
>>>>>  NSUID INTEGER;
>>>>> BEGIN
>>>>>  NSUID = 5;
>>>>>  SELECT MAX(K.NSUID) AS F_1
>>>>>       INTO NSUID
>>>>>    FROM KULLANIC K
>>>>>  WHERE K.NSUID = NSUID; /*this is my variable but oracle use this
>>>>> variable as a table field.*/
>>>>> END;
>>>>>
>>>>> is there any way use variable that name is same as field name?
>>>>>
>>>>>
>>>>> in InterBase
>>>>>
>>>>>  SELECT MAX(K.NSUID)
>>>>>    FROM KULLANIC K
>>>>>  WHERE K.NSUID = :NSUID  /* ':' this syntax uses to determine variable
>>>>> */
>>>>>       INTO :NSUID
>>>>>
>>>>> any help will be appreciated?
>>>>>
>>>> Use a different name for your variable, why not?
>>>>
>>>> Shakespeare
>>>> (what's in a name?)
>>> Please mod the above reply down, it is way too eloquent to be from an
>>> Oracle Developer
>>>
>> Please explain this. Why should one persist in naming a variable the same as
>> a column, if there is no good reason for this? In this group we don't "mod
>> down" replies . And if we would, yours would be a good candidate. But since
>> I've never seen contributions by you in this group (unless this is a
>> crossposted message), I guess you're new on the block, so you're forgiven.
>> I could have suggested to prefix the variable with v_ (v_nsuid). Which is in
>> fact no different then putting a : in front of it. Would that answer have
>> satisfied you? Not me!
>> And YES, I have been an Oracle Developer for more than 10 years. And it
>> seems Oracle Developers can be eloquent sometimes.
>>
>> Shakespeare
>> (What's in a mod?)

You have to change a lot more than just variable names unless the intention is to be the proud owner of one of the world's great nightmares.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Sat Dec 23 2006 - 11:25:28 CST

Original text of this message

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