PL/SQL cursor in procedure
It's been awhile since I've written anything in PL/SQL and I can't seem to
figure out what's wrong with my procedure. It looks correct from what I've
seen from others posts. Maybe you can help me figure it out.
CREATE OR REPLACE PROCEDURE export_all_ivt
IS
CURSOR tbl_cur IS
select A.TABLE_NAME
from DBA_TABLES A
join DBA_TABLES B ON A.TABLE_NAME = B.TABLE_NAME
where A.OWNER = 'TEST1'
and B.OWNER = 'TEST2'
and B.NUM_ROWS = 0
and A.NUM_ROWS > 0
and A.TABLE_NAME not in ('TABLE1', 'TABLE2', 'TABLE3')
order by A.TABLE_NAME, A.NUM_ROWS;
tbl_name tbl_cur%rowtype;
BEGIN
OPEN tbl_cur;
FETCH tbl_cur INTO tbl_name;
WHILE tbl_cur%FOUND
LOOP
FETCH tbl_cur INTO tbl_name;
EXIT WHEN tbl_cur%NOTFOUND;
dbms_output.put_line(tbl_name.table_name);
END LOOP;
CLOSE tbl_cur;
END export_all_ivt;
/
No comments:
Post a Comment