Re: SELECT with variables [message #36031] |
Tue, 30 October 2001 23:01 |
Srinivas
Messages: 138 Registered: June 2000
|
Senior Member |
|
|
The following PL/SQL will work for ur requirement :
create or replace procedure disp
as
xTableName varchar2(25):='emp';
xFieldName varchar2(25):='ename';
xValue NUMBER;
xQuery varchar2(100);
name varchar2(10) := 'CLARK';
begin
xQuery := 'SELECT SAL FROM ' || xTableName || ' where ' || xFieldName ||
' = ''' || name || '''';
dbms_output.put_line(xQuery);
execute immediate xQuery INTO xValue;
dbms_output.put_line(xValue);
end;
Regards,
Srini
----------------------------------------------------------------------
|
|
|