I've a SQL, whose where the predicate is well binded using bind varaible.
Now, I've a column whom I want to be used a bind variable.
But, the column which I am trying to bind uses a logic (case when statements) which will get change frequently.
I believe if I pass the column name as bind variable it'll be treated as string literal not as a column logic any workaround or suggestions
SQL> set serveroutput on;
SQL> declare
2 l_sql varchar2(200);
3 l_col varchar2(200);
4 l_where number:=1;
5
6 l_var1 varchar2(200);
7 l_var2 varchar2(200);
8 begin
9 l_col:='ceil(0.9) as col2 ';
10 l_sql:='select 1 as cola, :col2 from dual where 1 = :p1';
11 execute immediate l_sql into l_var1,l_var2 using l_col,l_where;
12 dbms_output.put_line(l_var1||'---'||l_var2);
13 end;
14 /
1---ceil(0.9) as col2
PL/SQL procedure successfully completed.
SQL>