Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Dynamic PL/SQL and boolean
Hi,
I try to use dynamic SQL but I have a problem with boolean variable.
Can anyone explain me how to do this :
My pl/sql:
CREATE OR REPLACE FUNCTION ps_if( as_condition IN BOOLEAN, as_true IN VARCHAR2, as_false IN VARCHAR2 ) RETURN VARCHAR2
IS
ls_retour VARCHAR2(2000);
BEGIN IF as_condition THEN
ls_retour := as_true;
ELSE ls_retour := as_false;
END IF; RETURN ls_retour;
EXCEPTION WHEN OTHERS THEN RETURN 'Error';
END;
/
show errors;
My test :
set serveroutput on
/
BEGIN DECLARE li_cursor INTEGER;
li_dummy INTEGER;
ls_temp VARCHAR2(2000);
BEGIN li_cursor := dbms_sql.open_cursor;
dbms_sql.parse( li_cursor, 'SELECT ps_si(1''>''2, ''toto'', ''tata'') from dual', dbms_sql.V7);
dbms_sql.define_column( li_cursor, 1, ls_temp, 2000);
li_dummy := dbms_sql.execute_and_fetch( li_cursor, true);
dbms_sql.column_value( li_cursor, 1, ls_temp);
dbms_sql.close_cursor( li_cursor);
dbms_output.put_line( ls_temp);
end;
end;
/
show errors
/
RESULT: ORA-00907: missing right parenthesis
ORA-06512: at "SYS.DBMS_SYS_SQL", line 239
ORA-06512: at "SYS.DBMS_SQL", line 32
ORA-06512: at line 13 Received on Mon Nov 20 2000 - 19:06:51 CST