Execute immediate not working..please help me out..!! [message #2246] |
Tue, 02 July 2002 00:20 |
pk
Messages: 12 Registered: September 2000
|
Junior Member |
|
|
declare
str varchar2(100);
begin
str:='select * from emp';
execute immediate str;
end;
/
Though saying that pl/sql completed successfully, but the result is not shown, i mean the query 'select * from emp' is not getting executed.Can anyone tell me what exactly is the problem?
pk
|
|
|
Re: Execute immediate not working..please help me out..!! [message #2260 is a reply to message #2246] |
Tue, 02 July 2002 09:01 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
In the context of PL/SQL, a select statement must return data INTO something (variable, PL/SQL table). There is no auto-display of the data from the result set. One option would be to loop through a cursor and display the results using dbms_output:
First, in SQL*Plus:
and then:
begin
for r in (select * from emp) loop
dbms_output.put_line('Employee #: ' || r.emp_no);
end loop;
end;
/
|
|
|