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;

/
1
  • I didn't read the code, only the introducing sentences of the OP. So my previous comment points at the wrong error. The answer of GerardH.Pille explains what is the problem.
    – miracle173
    Commented Aug 25, 2021 at 7:43

1 Answer 1

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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.