0

I'm trying to do a pl/sql with two loops. Inside second loop it gives me error:

ORA-00942.

I do the query manually and I don't have any error. Someone could help me please?

Thanks

begin
     DBMS_OUTPUT.PUT_line('begin' );

for i in ( select table_name from user_tables where table_name like 'A%002_AJOB') loop

     dbms_output.put_line(i.table_name);

     DBMS_OUTPUT.PUT_LINE('La tabla es ... ' || i.table_name );

for j in ( select job from i.table_name where status='Wait' ) loop

   dbms_output.put_line('Job is....' || j.job);

end loop;

end loop;

end;

/

user650034
  • 15
  • 2
  • 4

1 Answers1

2

You are trying to select from a table called 'table_name' in the schema i.

There's is probably no schema i, and if there was, it probably doesn't contain a table called 'table_name'.

What you're trying to do may be resolved using dynamic SQL, but you can't use a variable as table in PL/SQL.

miracle173
  • 7,797
  • 28
  • 42
Gerard H. Pille
  • 3,285
  • 1
  • 10
  • 13