My query:
declare
v_sql varchar2(4000);
cursor c_ppqa_tables is
select
job_id
from
jobs
where
INPUT_DOCUMENT_TYPE = 'test'
and to_char(PRE_PRINTING_END, 'MM/DD/YYYY') = '06/26/2023'; --to_char(sysdate, 'MM/DD/YYYY');
begin
for REC in c_ppqa_tables LOOP
v_sql := 'select * from PPQA_'||REC.job_id||'_O01_0 where REMOVAL_MARK = ''Y'' ';
execute IMMEDIATE v_sql;
end LOOP;
end;
When I run the query from c_ppqa_tables
by itself, I can get good output, I receive back 3 records. And then when I plug in the job_id from that into my v_sql
, and run it manually, I can pull back data, too.
Am I doing something wrong on how to display the results for v_sql
?