I've got one further issue thats driving me nuts.
Here is the code I'm running,
$sth->bind_param($_, $execute_args[$_]) for
([EMAIL PROTECTED]);
$sth->bind_param_inout(scalar
@execute_args+1,\$new_id,38);
if($sth->execute())
{
......
N.b. using scalar @execute_args produces rebind
errors, unless I do the +1." Can you explain why I
shouldn't use the +1??
Here is the SQL I'm generating:-
INSERT INTO table (CompID, User_ID, Referral,
Newregistration, Phonecontact, Created, Updated)
VALUES (COMPID_seq.nextval, ?, ?, ?, ?,
from_unixdate_func(1095168082),
from_unixdate_func(1095168082)) returning CompID into
?
And here is a dump of the @execute_args array
$VAR1 = 3738;
$VAR2 = 'Y';
$VAR3 = 'Y';
$VAR4 = 'Y';
When I run this query I get the following error:-
DBD::Oracle::st execute failed: ORA-01722: invalid
number (DBD ERROR: OCIStmtExecute) at
/opt/apps/embperl2-apache-matt/perl/perl-5.6.1/lib/site_perl/5.6.1/III/Oracle/Object.pm
line 974.
If I run the insert without the column which contains
a number (e.g. run the query without the User_ID
value, so that ALL the variables passed to the binds
are of type varchar (perl string) it works. And if I
run the query for only Numbers it works, but as soon
as I try to have strings and numbers inside my
@execute_args array my code breaks. We're running
Oracle 8i.
If I expressly say to_num(?) for the num column Then
the query works when the rest of the columns are
strings.
This whole issue seems to be 'quirky' and it's
probably my lack of Oracle thats causing me to do
somethign stupid, but I can't tell what.
Any help would be so much appreciated!
Marty
--- Martin Moss <[EMAIL PROTECTED]> wrote:
> Thanks for you help,
>
> Marty
>
>
> --- Tim Bunce <[EMAIL PROTECTED]> wrote:
> > On Tue, Sep 14, 2004 at 12:34:09AM +0200, Jenda
> > Krynicky wrote:
> > > From: Tim Bunce <[EMAIL PROTECTED]>
> > > >
> > > > 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);
> > > }
> > > }
> >
> > No need. See below.
> >
> > > So that this could be shortened to
> > >
> > > $sth->bind_params([EMAIL PROTECTED]); # default
> > position is 1
> > >
> >
>
$sth->bind_param_inout($#execute_args+1,\$new_id,38);
> >
> > Without adding any new methods it can be shortened
> > to
> >
> > $sth->bind_param($_, $execute_args[$_]) for
> > ([EMAIL PROTECTED]);
> > $sth->bind_param_inout($#execute_args+1,
> \$new_id,
> > 38);
> >
> > I'll add that to the docs.
> >
> > Tim.
> >
> > p.s. I'd use "scalar @execute_args" or
> > "[EMAIL PROTECTED]" instead of "$#execute_args+1".
> >
>
>
>
>
>
>
___________________________________________________________ALL-NEW
> Yahoo! Messenger - all new features - even more fun!
> http://uk.messenger.yahoo.com
>
___________________________________________________________ALL-NEW Yahoo! Messenger -
all new features - even more fun! http://uk.messenger.yahoo.com