Setting a user variable from a bind variable
David McCormack, May 13, 2009 - 2:44 am UTC
Your article was incredibly useful as I have been banging my head on this for quite a while. I have attached my simple example of how I used this "feature" to set a user variable from a bind variable. I don't guarantee it is 100% as you are the guru not me.
SET SERVEROUTPUT ON
define userVar = ''
variable bindVar VARCHAR2(15);
declare
begin
if (1 = 1) then
DBMS_OUTPUT.PUT_LINE('In 1 = 1');
:bindVar := 'here';
else
DBMS_OUTPUT.PUT_LINE('not in 1 = 1');
:bindVar := 'there';
end if;
end;
/
column X new_val userVar
select :bindVar X from dual;
define userVar