PLSQL error -
674481Mar 17 2010 — edited Mar 17 2010I can't seem to identify the souce of my error. I have been running this PL/SQL and checking line by line after I got help from Heral. But I can't seem to fine out what to do with the identifier b_jobid etc.
All I want to do is create dynamic PLSQL to drop tables from all_tables or dba_objects that is define in the second corsor (c_job_status).
I want the result to look like this:
My problem is how to append the five digit number after "JOB_" to get the below result and do an immediate execute.
drop table JOB_25875_CMD_SETUP1;
drop table JOB_25071_JED_COUNTRY_REPORT;
drop table JOB_25071_JED_STATE_REPORT;
Check the code and error that follows.
set serveroutput on
declare
cursor obj_cursor is
select object_name,
object_type,
owner
from dba_objects
where owner='ITA'
and object_type in ('TABLE','VIEW')
and object_name like 'JOB_%';
cursor c_job_status (b_job_id in number) is
Select jobid,
ownerid,
starttime,
endtime
from ita.tpis32_job_status
where
starttime < sysdate - 60
and num_lines > 1000000
and jobid = b_jobid;
r_job_status c_job_status%rowtype;
wk_job VARCHAR2(500);
WK_SQL VARCHAR2(500);
WK_JOBSTR VARCHAR2(500);
out_f utl_file.file_type;
BEGIN
wk_jobstr:='JOB_' || ltrim(to_char(wk_job)) || '%';
for wk_rec in obj_cursor
loop
if wk_rec.object_type='TABLE'
then
wk_sql:='drop table ' || wk_rec.object_name;
dbms_output.put_line (wk_sql);
end if;
open c_job_status(jobid);
fetch c_job_status into r_job_status;
--<< Do your work with above >>
close c_job_status;
end loop;
end;
/
and jobid = b_jobid;
*
ERROR at line 20:
ORA-06550: line 20, column 13:
PL/SQL: ORA-00904: "B_JOBID": invalid identifier
ORA-06550: line 12, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 11, column 8:
PLS-00341: declaration of cursor 'C_JOB_STATUS' is incomplete or malformed
ORA-06550: line 21, column 14:
PL/SQL: Item ignored
ORA-06550: line 35, column 20:
PLS-00201: identifier 'JOBID' must be declared
ORA-06550: line 35, column 2:
PL/SQL: SQL Statement ignored
ORA-06550: line 36, column 27:
PLS-00320: the declaration of the type of this expression is incomplete or
malformed
ORA-06550: line 36, column 3:
PL/SQL: SQL Statement ignored