Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Dynamic SQL

Re: Dynamic SQL

From: Viktor <stant_98_at_yahoo.com>
Date: Wed, 17 Jan 2001 14:15:20 -0800 (PST)
Message-Id: <10744.126939@fatcity.com>


Hey,

You can't use the INTO clause in Dynamic PL/SQL. You have to use DBMS_SQL.DEFINE_COLUMN and DBMS_SQL.COLUMN_VALUE. Try this:

CREATE OR REPLACE PROCEDURE cc1(source IN VARCHAR2) is

  name               VARCHAR2(30);
  source_cursor      INTEGER;
  ignore             INTEGER;

BEGIN
  source_cursor := dbms_sql.open_cursor;   DBMS_SQL.PARSE(source_cursor,
       'SELECT table_name 
	    FROM user_tables 
	    where table_name = UPPER('''||source ||''')'
,DBMS_SQL.NATIVE);
       DBMS_SQL.DEFINE_COLUMN(source_cursor, 1, name,
30);
	   DBMS_SQL.COLUMN_VALUE(source_cursor, 1, name);		 
  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;
/  


Do You Yahoo!? Received on Wed Jan 17 2001 - 16:15:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US