Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Dynamic SQL
Hello,
can anybody help me to understand my mistake?
I tried to create procedure with 'table_name' parameter, which writes result
of select -> Table exists or not. Procedure doesn't work properly - existing
table is not found.
Thanks
CREATE OR REPLACE PROCEDURE cc1(source IN VARCHAR2) is
name VARCHAR2(30); source_cursor INTEGER; ignore INTEGER;
'SELECT table_name INTO name FROM user_tables where table_name =
source' ,DBMS_SQL.native);
ignore := DBMS_SQL.EXECUTE(source_cursor);
DBMS_OUTPUT.PUT_LINE('Table exists ');
DBMS_SQL.CLOSE_CURSOR(source_cursor);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Table does not exist ');
IF DBMS_SQL.IS_OPEN(source_cursor) THEN
DBMS_SQL.CLOSE_CURSOR(source_cursor);
END IF;
END;
/
Received on Wed Jan 17 2001 - 08:57:24 CST