Billy has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys. I have the following PLSQL procedure prototype as follows:

PROCEDURE validate_user ( p_event IN EVENT, p_user IN valid_users.userid%TYPE, p_password_only IN boolean, v_return_string OUT VARCHAR2)


My driver script for this is very simple:

#!/usr/bin/perl use DBI; $ENV{'ORACLE_HOME'} = '/space/oracle/app/oracle/product/8.1.5'; my $dbh = DBI->connect('my dsn',"bla bla","bla bla") or die("Can't con +nect to Oracle database: $DBI::errstr\n"); my $sql = "BEGIN campaign.validate_user(?, ?, ?, ?); END;"; my $sth = $dbh->prepare($sql); $sth->bind_param(1, 'V2001'); $sth->bind_param(2, 'billy'); $sth->bind_param(3, TRUE); my $error_string; my $return_code; $sth->bind_param_inout(4, \$return_code,1000); $sth->execute() or die("Execution error: $DBI::errstr\n"); print $error_string." : ".$return_code."\n"; $dbh->disconnect;


I'm having trouble with passing the value TRUE to the PLSQL procedure as perl seems to want to send it as a string which the procedure complains about.

The error returned is:

DBD::Oracle::st execute failed: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'VALIDATE_USE +R' ORA-06550: line 1, column 7: PL/SQL: Statement ignored (DBD ERROR: OCIStmtExecute) at ./nmsd.pl lin +e 27. Execution error: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'VALIDATE_USE +R' ORA-06550: line 1, column 7: PL/SQL: Statement ignored (DBD ERROR: OCIStmtExecute)


A way around it would be to change the stored procedure to accept a value 0 or 1 and interpret it as false and true, but I would rather sort this out on the perl end if possible :-)
Thanks for any help in advance.
Billy.

Replies are listed 'Best First'.
Re: Passing boolean value to PLSQL procedure
by agoth (Chaplain) on Jul 10, 2001 at 15:33 UTC
    Does your procedure compile on oracle in the first place??
    Is EVENT a valid type?
    Can you be sure from those errors that its the true thats the problem? and not:

    p_user IN valid_users.userid%TYPE

    Just thoughts, I don't have access to Oracle at the moment to be able to test TRUE out for you.
    Have you tried passing in 1 for true?? and 'TRUE' quoted?

      Hi. Yes the procedure does compile and EVENT is a valid type.
      I have run the procedure in SQLPLUS and it works fine With the value TRUE (or FALSE), but if I quote it (ie. 'TRUE') it returns the same error as my perl script.
      I have tried passing values 1, 0, T, F but have had no joy. The procedure does seem to be expecting the value TRUE or FALSE, but not the strings 'TRUE' or 'FALSE'. Cheers. BIlly.
        I have a feeling you can use bind to tie a specific variable to a datatype but I'm reaching here.

        I had problems in the past getting oracle to accept NULL for what it was and not a string, but cant yet find the code sample.
        Sorry I can't be any more help