Re: Why can't a variable have the same name as a table ...

From: Samuel Leung <m2624526_at_netvigator.com>
Date: Fri, 20 Aug 1999 11:21:04 +0800
Message-ID: <7pigg8$tu1$1_at_imsp009a.netvigator.com>


Logically variable can have the same name as tables, but in the naming convention of PL/SQL, local
variable and parameters take precedence over the names of database tables. In your case, PL/SQL
thinks the 'customer' as a variable in the insert statement, so it returns error. In this case,
you can prefix the table name with a schema name, e.g.

  insert into your_name.customer values (customer);

  [replace 'your_name' with the table owner's name]

Samuel

thalabi_at_my-deja.com wrote in message <7phbqg$3rq$1_at_nnrp1.deja.com>...
>Hi,
>
>When I create the following procedure;
>----------------------------------------------------
>create or replace procedure customer_add (
> customer customer.name%type)
>as
>begin
>insert into customer values (customer_add.customer);
>end;
>----------------------------------------------------
>I get the error;
>PLS-00356: 'CUSTOMER' must name a table to which the user has
> access
>
>The message is kind of bogus because I DO have access to the table
>customer and if I change the variable name from customer to cust the
>procedure compiles ok. I think the problem is having a local variable
>the same as a table name.
>
>What is the work around? I must have the paramter named customer and not
>something else.
>
>Regards
>TH
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Fri Aug 20 1999 - 05:21:04 CEST

Original text of this message