is there a logical error in the following procedure that I cannot find, can you find what it is? The procedure below causes the following error:
ora-01001 invalid cursor 01001
and this is the procedure:
CREATE OR REPLACE PROCEDURE P_C is
v_tab_name varchar2(40);
var1 varchar2(2000);
var2 varchar2(2000);
tab_var varchar2(2000);
CURSOR get_tables IS
SELECT tab.table_name
FROM user_tables tab;
CURSOR get_columns IS
SELECT DISTINCT cols.column_name
FROM user_tab_cols cols
WHERE cols.table_name = v_tab_name;
BEGIN
var1 := null;
for gettab in get_tables
LOOP
tab_var :=gettab.table_name;
for getcols in get_columns
LOOP
if var1 is null then
var1 :=getcols.column_name;
else
var1 := var1 ||' , '|| getcols.column_name;
end if;
END LOOP;
CLOSE get_columns;
END LOOP;
CLOSE get_tables;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
end P_C;
source
share