View Single Post
  #6 (permalink)  
Old 09-07-10, 13:01
dayneo dayneo is offline
Registered User
 
Join Date: Oct 2002
Location: Cape Town, South Africa
Posts: 161
Wink

Here's one more example... If you are in fact using stored procedures, and you absolutely have to have parameters that are named the same as your column, then you could use:
Code:
CREATE OR REPLACE procedure lasttouch(user_name in testparameters.user_name%type) as
begin
execute immediate 'update testparameters set last_accessed=sysdate where user_name = :user_name' using user_name;
end;
/
Note though that this is should be used as a last resort. The above code makes use of EXECUTE IMMEDIATE which compiles SQL on the fly and executes it. The USING statement tells it to use the parameter value and ensures that bind variables are being used through the use of the colon.

Performance may become an issue here depending on your Oracle Server and Session parameters (I would advise the use of session cached cursors if you use the above method).

Last edited by dayneo; 09-07-10 at 13:03. Reason: More accurate code sample
Reply With Quote