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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to send multiple bind vars in perl DBI?

Re: How to send multiple bind vars in perl DBI?

From: Andy Hassall <andy_at_andyh.co.uk>
Date: Mon, 30 Jun 2003 22:08:31 +0100
Message-ID: <oh91gv0163kbdiu93s5q9jodgr9p27u4l0@4ax.com>


On 30 Jun 2003 15:16:45 GMT, revjack <revjack_at_revjack.net> wrote:

>I have a perl DBI script that connects to a remote machine
>and sends a single value to a stored procedure. The script
>reads the returned data just fine.
>
>I have been informed that the remote stored procedure now
>requires three values instead of one. I'm pretty sure that I
>will need to change my execute() statement to pass a list
>instead of a scalar. Sending it a list now results in the
>"called with 3 bind variables when 1 are needed" error,
>which is not surprising.
>
>What I don't know, is, how do I change the procedure call:
>
> STORED_PROC01(?);
>
>such that it accepts a list instead of a single value?
>
>This is the essence of what I have, and it works with a single parameter:
>
>#----------------------------------
>$data = 'foo';
>$sql = q(
>BEGIN
> dbms_output.enable(1000000);
> STORED_PROC01(?);
>END;
>);
>$dbh = DBI->connect(stuff);
>$sth = $dbh->prepare($sql);
>$sth->execute($data);
>#----------------------------------
>
>Now I need to start sending STORED_PROC01 lists like:
>
> 'foo', 'bar', 'baz'
>or
> NULL, NULL, '012345'
>or
> 'foo', NULL, NULL
>etc.
>
>Can anyone point me to a clue?

 Scroll down to Example 3 in the PL/SQL Examples part of the DBD::Oracle documentation. It shows a call to a two-argument stored procedure.

http://theoryx5.uwinnipeg.ca/CPAN/data/DBD-Oracle/Oracle.html#PL%2fSQL_Examples

 If they're simply IN parameters - just pass multiple values to $dbh->execute... it takes an array of parameter values...

$dbh->execute($value1, $value1); # etc.

--
Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Received on Mon Jun 30 2003 - 16:08:31 CDT

Original text of this message

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