Monday, July 21, 2008

Pass Bind Variable to Substitution Variable

How to pass "order by" clause built in pl/sql block over to sql script.

COLUMN command with NEW_VALUE option can be used.

-- declare a bind variable
var bind_var varchar2(100)

-- assign it a value
begin
:bind_var :='order by name';
end;
/
--pass the value into substitution variable
COLUMN b_var_alias new_value subs_var
select :bind_var b_var_alias from dual;

select name from TEST &&subs_var;

No comments:

search engine

Custom Search