Home » SQL & PL/SQL » SQL & PL/SQL » Execute immediate not working..please help me out..!!
Execute immediate not working..please help me out..!! [message #2246] Tue, 02 July 2002 00:20 Go to next message
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 Go to previous message
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:

set serveroutput on


and then:

begin
  for r in (select * from emp) loop
    dbms_output.put_line('Employee #: ' || r.emp_no);
  end loop;
end;
/
Previous Topic: Finding modified Records
Next Topic: No. of Rows
Goto Forum:
  


Current Time: Fri Apr 19 11:29:34 CDT 2024