Home » SQL & PL/SQL » SQL & PL/SQL » exec immediate
exec immediate [message #39818] Tue, 13 August 2002 22:19 Go to next message
Raju
Messages: 74
Registered: March 1999
Member
Hello,

Iam getting error with exec immediate. Pl. correct the query.

RAJ> declare
2 type ref1 is ref cursor;
3 r1 ref1;
4 l_count number;
5 cursor c1 is select * from user_tables;
6 begin
7 dbms_output.enable(100000);
8 dbms_output.put_line(rpad('TABLE NAME',30,' ')|| chr(9)||'NO OF RECORDS');
9 for crec in c1 loop
10 execute immediate 'select count(*) from '||crec.table_name into l_Count;
11 dbms_output.put_line(rpad(crec.table_name,30,' ')|| chr(9)||l_count);
12 end loop;
13 end;
14 /
declare
*
ERROR at line 1:
ORA-06550: line 10, column 9:
PLS-00103: Encountered the symbol "IMMEDIATE" when expecting one of the following:
:= . ( @ % ;
The symbol ":= was inserted before "IMMEDIATE" to continue.
ORA-06550: line 10, column 60:
PLS-00103: Encountered the symbol "INTO" when expecting one of the following:
. ( * @ % & = - + ; < / > in mod not rem an exponent (**)
<> or != or ~= >= <= <> and or like between is null is not ||
The symbol ". was inserted befor

regards,
Raju.
Re: exec immediate [message #39824 is a reply to message #39818] Wed, 14 August 2002 08:50 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
There is nothing wrong with your code, but you have to be running on Oracle 8i or later to use NDS (execute immediate). Since you must be on 8.0 or earlier, you'll need to use DBMS_SQL instead.
Previous Topic: Re: Summing up data by quarters
Next Topic: Re: query giving wierd results
Goto Forum:
  


Current Time: Fri Apr 26 14:33:55 CDT 2024