Home » SQL & PL/SQL » SQL & PL/SQL » Re: SELECT with variables
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

----------------------------------------------------------------------
Previous Topic: SQL Query - return values from 2 rows as 1 row??
Next Topic: to create a table structure from an existing structure
Goto Forum:
  


Current Time: Wed Dec 25 10:29:38 CST 2024