Dynamic SQL problem

From: Michael J Belgard <MJ.Belgard_at_postoffice.worldnet.att.net>
Date: 1997/09/10
Message-ID: <5v6u6i$7mt_at_bgtnsc03.worldnet.att.net>#1/1


i successfully compiled the following procedure but received errors that follow the procedure. Any help would be greatly appreciated.

CREATE or REPLACE PROCEDURE test_run ( from_date DATE, class_rank VARCHAR2,

                                       grad_yr NUMBER, 
                                      intend_term NUMBER) AS
	cursor1 integer;
     	rows_processed integer;
     	counts number;
BEGIN
	cursor1 := dbms_sql.open_cursor;
     	dbms_sql.parse (cursor1, 'SELECT COUNT(*) 
                        FROM PROSPECT P, MIX_CODE_LOG M,
HIGH_SCHOOL_ATTENDED H, 
                        academic_term a
                        WHERE P.ENTITY_ID=M.PROSPECT_ID AND
P.ENTITY_ID=H.PROSPECT_ID 
                        and p.intended_term_id=a.entity_id AND 
                        M.MIX_CODE_DATE_CHANGED <  to_date(' ||
from_date ||', ''dd-mon-yy'' )  
                        AND P.CLASS_RANK_CODE = ' || class_rank || ' AND 
                        H.GRAD_YEAR = to_number( ' || grad_yr || ' )
                        AND A.ENTITY_ID =  to_number(' ||
intend_term||')' , 
                        dbms_sql.v7);
	dbms_sql.define_column (cursor1, 1, counts);
    	   rows_processed := dbms_sql.execute (cursor1);
	loop
	    if dbms_sql.fetch_rows (cursor1) > 0 then
		dbms_sql.column_value (cursor1, 1, counts);
		dbms_output.put_line(counts);
	    else
		exit;
	    end if;
	end loop;
	dbms_sql.close_cursor (cursor1);
EXCEPTION
	WHEN OTHERS THEN
		dbms_output.put_line(sqlerrm);
		if dbms_sql.is_open (cursor1) then
			dbms_sql.close_cursor (cursor1);
                end if;

END;
/

SQL> begin
  2 test_run(''11-may-93'', 'O', 1990, 20);   3 end;
  4 /
begin
*
ERROR at line 1:
ORA-06550: Message 6550 not found; No message file for product=RDBMS73, facility=ORA; arguments:
[2] [13] [PLS-00103: Encountered the symbol "11" when expecting one of the following:
. ( ) , * _at_ % & | = - + < / > in mod not range rem => .. an exponent (**) <> or != or ~= >= <= <> and or like between is null is not ||
The symbol "(" was substituted for "11" to continue. ]
ORA-06550: Message 6550 not found; No message file for product=RDBMS73, facility=ORA; arguments:
[2] [22] [PLS-00103: Encountered the symbol "" when expecting one of the following:
) , * & | = - + < / > in mod not rem => .. an exponent (**)
<> or != or ~= >= <= <> and or like between is null is not ||
The symbol "," was substituted for ]
ORA-06550: Message 6550 not found; No message file for product=RDBMS73, facility=ORA; arguments:
[2] [40] [PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( ) , * % & | = - + < / > in mod not range rem => .. an exponent (**) <> or != or ~= >= <= <> and or like between is null is not ||
The symbol ")" was ] Received on Wed Sep 10 1997 - 00:00:00 CEST

Original text of this message