ambiguity in variable name and field name
suppose we have a table:-
customer_info(customer_id,first_name,last_name);
and we are to write a stored procedure like below
************
create procedure sp_del_customer( IN customer_id char(17))
begin
delete from customer_info where customer_id=customer_id;
end;
************
above procedure deletes all the rows from the table customer_info because it can't distinguish between the variable name and the field name and hence evaluates the where clause true for every rows. There won't be problem if we were using @customer_id to denote the variable or if it had some thing else as its name.
To solve the problem, i am appending the table name before each field name like below
************
create procedure sp_del_customer( IN customer_id char(17))
begin
delete from customer_info a where a.customer_id=customer_id;
end;
************
is there any better solution..?
thanks in advance
Subject
Views
Written By
Posted
ambiguity in variable name and field name
4643
April 07, 2005 02:21AM
6746
April 07, 2005 04:51AM
2686
April 07, 2005 11:06PM
2801
April 08, 2005 03:45AM
2857
April 14, 2005 03:47AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.