How to use Stored Procedure?


I'm new to Oracle and have noticed a rather strange thing about Oracle SQL
which took me a couple of hair-pulling hours to resolve:

Take a procedure:

PROCEDURE myproc(colname IN TABLE.colname%TYPE) AS
BEGIN
    update TABLE set colname = colname;
END

So, I'm passing in a parameter with the same name as the column I'm updating
(nothing unusual about that in Sybase).  But Oracle SQL overrides the
variable colname and treats it like a column so the procedure above does
absolutely nothing!

Is there a way I can tell Oracle to update the column with the variable or
do I have to rename all my variables to ensure there is no naming conflict
with the table columns?



Ans1:

Yes, regrettably you need to do this (frankly, I find it less confusing)

Hth,

Sybrand Bakker, Oracle DBA



Ans2:

I think you can do:

update TABLE set colname = myproc.colname ;
 
 

Hosted by www.Geocities.ws

1