Does anyone have an example of how to set up and call an oracle function
that returns a number?  Embedding within an sql statement as I normally
use a query does not work, and I receive errors if I attempt to format
it like an example in the dbd document:


Here is a section of my code.

    my $catalog="SMB";
    my $code=$info->{".code"};
    my $itemid="10501076150130";
    my $dbh = DBI->connect('DBI:Oracle:ORCL','a', 'b')
                    or die "Couldn't connect to database: " .
DBI->errstr;
    my $sth = $dbh->prepare("SELECT item_owner FROM item where item_id =
'$catalog$itemid'")
                    or die "Couldn't prepare statement: " .
$dbh->errstr;
    my $qty;
    my @data;
    $sth->execute()             # Execute the query
                or die "Couldn't execute statement: " . $sth->errstr;
        (@data) = $sth->fetchrow;
        $qty = @data[2];
    print "data returned = @data\n";

  $sth = $dbh->prepare("BEGIN :result = getpickableqty(:id) END;");
  $sth->bind_param(":id", "$catalog$itemid");
  my ($result) = 0;
  $sth->bind_param_inout(":result",  \$result,  100);
  $sth->execute();
  print "func_name returned '$result' \n";


Results of the program is this:

data returned = SMB10501076150130                           *****  The
regular SQL works ok  ******
DBD::Oracle::st execute failed: ORA-06550: line 1, column 15:
PLS-00103: Encountered the symbol "=" when expecting one of the
following:

   := . ( @ % ; indicator
ORA-06550: line 1, column 37:
PLS-00103: Encountered the symbol "END" when expecting one of the
following:

   . ( * % & - + ; / at mod rem return returning
   <an exponent (**)> and or || (DBD ERROR: OCIStmtExecute) at getinv.p
line 75.
func_name returned '0'



Can anyone tell me what code I have set up incorrectly here?  Please
reply directly as I just subscribed to the list.

Thanks

Carlin Anderson
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to