bind_param_inout

bind_param_inout

am 13.09.2004 19:22:13 von martin_moss

All,

Can I do this?

$sth->bind_param_inout($#execute_args+1,\$new_id,38);
$sth->execute(@execute_args);

When I try I get the following error
Can't rebind or change param :p6 in/out mode after
first bind (1 => 0) at ...........

I wish to pass several arguments, into the sth, I wish
to use placeholders so I can cache this $sth,

So in mysql, I would have used the 'last_insert_id'
mechanism to get my auto incremented number, but I'm
now using oracle, and I'd found an example of using
bind_param_inout but without any args to execute,
which uses my autoincrement sequence.

Can anybody shed some light on this?

Regards

Marty





___________________________________________________________A LL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

Re: bind_param_inout

am 13.09.2004 20:26:07 von Tim.Bunce

On Mon, Sep 13, 2004 at 06:22:13PM +0100, Martin Moss wrote:
> All,
>
> Can I do this?
>
> $sth->bind_param_inout($#execute_args+1,\$new_id,38);
> $sth->execute(@execute_args);
>
> When I try I get the following error
> Can't rebind or change param :p6 in/out mode after
> first bind (1 => 0) at ...........
>
> I wish to pass several arguments, into the sth, I wish
> to use placeholders so I can cache this $sth,

Use bind_param() or bind_param_inout() for all the params
and then call execute() with no arguments.

Tim.

Re: bind_param_inout

am 14.09.2004 00:34:09 von Jenda

From: Tim Bunce
> On Mon, Sep 13, 2004 at 06:22:13PM +0100, Martin Moss wrote:
> > All,
> >
> > Can I do this?
> >
> > $sth->bind_param_inout($#execute_args+1,\$new_id,38);
> > $sth->execute(@execute_args);
> >
> > When I try I get the following error
> > Can't rebind or change param :p6 in/out mode after
> > first bind (1 => 0) at ...........
> >
> > I wish to pass several arguments, into the sth, I wish
> > to use placeholders so I can cache this $sth,
>
> Use bind_param() or bind_param_inout() for all the params
> and then call execute() with no arguments.
>
> Tim.

I wonder ... how about adding a method bind_params() like this:

sub bind_params {
my $sth = shift;
my $pos = (ref($_[0]) ? 1 : shift);
for my $param (@{$_[0]}) {
$sth->bind_param($pos++, $param);
}
}

So that this could be shortened to

$sth->bind_params(\@execute_args); # default position is 1
$sth->bind_param_inout($#execute_args+1,\$new_id,38);

I know I can have the loop in the script, but this looks kinda more
readable to me.

Sorry if this was already rejected ;-)

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

Re: bind_param_inout

am 21.10.2004 18:51:40 von lembark

> I wonder ... how about adding a method bind_params() like this:
>
> sub bind_params {
> my $sth = shift;
> my $pos = (ref($_[0]) ? 1 : shift);
> for my $param (@{$_[0]}) {
> $sth->bind_param($pos++, $param);
> }
> }
>
> So that this could be shortened to
>
> $sth->bind_params(\@execute_args); # default position is 1
> $sth->bind_param_inout($#execute_args+1,\$new_id,38);
>
> I know I can have the loop in the script, but this looks kinda more
> readable to me.
>
> Sorry if this was already rejected ;-)

I've already posted a working version of this to the list,
if you like I can send you a copy to test.


--
Steven Lembark 85-09 90th Street
Workhorse Computing Woodhaven, NY 11421
lembark@wrkhors.com 1 888 359 3508