Re: Huh? 4=3?

Bill Ward <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <CAKGT8WqQOjwPcGcjW1hWsw=nOhaBP3cgpb-kBbShzp_v4mMVMw@mail.gmail.com>
Cool. That whole scalar vs list context thing is one of Perl's biggest
strengths, but also one of its biggest weaknesses (in that it is a common
source of bugs like this). When you see head-scratching problems, it's one
of the first things to look for.


On Wed, May 8, 2013 at 9:39 AM, Bruce Johnson
<[email protected]>wrote:

> Well, changing the code to:
>
> my $eid=$mesg->entry($n)->get_value('emplId');
> my $etp=$mesg->entry($n)->get_value('employeeType');
> my $efte=$mesg->entry($n)->get_value('employeeFTE');
> my $ear=$mesg->entry($n)->get_value('employeeTotalAnnualRate');
>
> $csr_emp_info->execute($eid,$etp,$efte,$ear);
>
> like you suggested fixed it.
>
> Thanks.
>
> On May 8, 2013, at 9:30 AM, Bill Ward <[email protected]> wrote:
>
> > My guess is that get_value() is returning an empty array rather than an
> undef scalar when the values are null. Try copying each one to a scalar
> variable and including the list of variables in the execute(). It'd be more
> readable that way anyway. Or if you must put them all one one line like
> this, add the scalar() function on each argument.
> >
> >
> > On Wed, May 8, 2013 at 9:18 AM, Bruce Johnson <
> [email protected]> wrote:
> > Getting the error:
> >
> > DBD::Oracle::st execute failed: called with 3 bind variables when 4 are
> needed [for Statement "insert into employee_fte_annualrate_l (emplid,
> emptype_cd, fte, annual_rate) values(?,?,?,?)" with ParamValues:
> :p1='22057713', :p2='R', :p3='1', :p4='47311'] at /home/oraweb/perl/frs/
> kfsupdate.pl line 64, <DATA> line 581.
> >
> > I'm pretty sure I count 4 placeholders and 4 parameter values in that
> error message, so where is the '3 bind variables' coming from?
> >
> > here's the cursor definition:
> >
> > my $csr_emp_info = $lda->prepare("insert into employee_fte_annualrate_l
> (emplid, emptype_cd, fte, annual_rate) values(?,?,?,?)");
> >
> > I'm pulling the data from an LDAP query, here's the offending line 64
> (where $mesg is the returned LDAP object):
> >
> > $csr_emp_info->execute($mesg->entry($n)->get_value('emplId'),
> $mesg->entry($n)->get_value('employeeType'),$mesg->entry($n)->get_value('employeeFTE'),$mesg->entry($n)->get_value('employeeTotalAnnualRate'));
> >
> > All the columns allow null entries, and these are all single-valued
> entries in the LDAP schema.
> >
> >
> > --
> > Bruce Johnson
> > University of Arizona
> > College of Pharmacy
> > Information Technology Group
> >
> > Institutions do not have opinions, merely customs
> >
> >
> >
> >
> >
> > --
> > Check out my LEGO blog at brickpile.com
> > Follow/friend me: Facebook • Flickr • Twitter • LinkedIn
>
> --
> Bruce Johnson
> University of Arizona
> College of Pharmacy
> Information Technology Group
>
> Institutions do not have opinions, merely customs
>
>
>


-- 
Check out my LEGO blog at brickpile.com <http://www.brickpile.com/>
Follow/friend me: Facebook <http://facebook.com/billward> •
Flickr<http://flickr.com/photos/billward/>•
Twitter <http://twitter.com/williamward> •
LinkedIn<http://www.linkedin.com/pub/william-ward/63/393/985/>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.