Hello all,
when i jot, select &col from emp where &name = 'JOHN'; on the SQL> prompt, i am asked for the input for col and name and when i provide the following, the query works perfectly.
But when i write it in a procedure and substitute the &col and &name with some variables and run the procedure.. there is no results fetched. the &name when replaced with a variable, is considered as a value and not as a column name...
I want the program to consider it as column name! Please help me with the solution.
Eg:
declare
coladdress varchar2(20) := 'coladdress';
colname varchar2(20) := 'colname';
address varchar2(20);
Begin
select coladdress into address from emp where colname = 'JOHN';
dbms_output.put _line(address);
end;
/
when i jot, select &col from emp where &name = 'JOHN'; on the SQL> prompt, i am asked for the input for col and name and when i provide the following, the query works perfectly.
But when i write it in a procedure and substitute the &col and &name with some variables and run the procedure.. there is no results fetched. the &name when replaced with a variable, is considered as a value and not as a column name...
I want the program to consider it as column name! Please help me with the solution.
Eg:
declare
coladdress varchar2(20) := 'coladdress';
colname varchar2(20) := 'colname';
address varchar2(20);
Begin
select coladdress into address from emp where colname = 'JOHN';
dbms_output.put _line(address);
end;
/
Comment