Trying to drop all tables from my schema with no rows?
-
04-10-2019 - |
Question
I am trying to drop all tables in schema with no rows,but when i am executing this code i am getting an error
THis is the code:
create or replace procedure tester
IS
v_count NUMBER;
CURSOR emp_cur
IS
select table_name from user_tables;
BEGIN
FOR emp_rec_cur IN emp_cur LOOP
EXECUTE IMMEDIATE 'select count(*) from '|| emp_rec_cur.table_name INTO v_count ;
IF v_count =0 THEN
EXECUTE IMMEDIATE 'DROP TABLE '|| emp_rec_cur.table_name;
END IF;
END LOOP;
END tester;
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "identifier": expecting one of: "badfile, byteordermark, characterset, data, delimited, discardfile, exit, fields,
fixed, load, logfile, nodiscardfile, nobadfile, nologfile, date_cache, processing, readsize, string, skip, variable"
KUP-01008: the bad identifier was: DELIMETED
KUP-01007: at line 1 column 9
ORA-06512: at "SYS.ORACLE_LOADER", line 14
ORA-06512: at line 1
ORA-06512: at "SCOTT.TESTER", line 9
ORA-06512: at line 1
Solution
The error is being raised by ORACLE_LOADER. I suspect your loop is finding an external table, which has a problem with its definition - the KUP-01008 is complaining about a keyword "DELIMETED", but the external table syntax includes the keyword "DELIMITED".
If you don't intend to drop the external tables, perhaps you need to omit them from the query, e.g.:
CURSOR emp_cur IS
SELECT table_name FROM user_tables
MINUS
SELECT table_name FROM user_external_tables;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow