[Arsperl-users] RE: DBI error on bind_columns - fixed
Brought to you by:
jeffmurphy
|
From: Kelly L. <kel...@ra...> - 2005-05-18 13:51:21
|
Sorry for the duplicate email this morning, I meant this to be a reply
saying I found the problem (I didn't add the new field to the *bind =
columns*
statement) but I fat-fingered the 'send' keys. :^)
=20
Kelly Logan
Rapid Technologies
(313) 645-4552
kel...@ra...
-----Original Message-----
From: Kelly Logan [mailto:kel...@ra...]=20
Sent: 05/18/2005 9:43 AM
To: 'ars...@ar...'
Subject: FW: DBI error on bind_columns
G'day all,
=20
This is an odd one. I have a script that uses DBD:ODBC to connect to an =
SQL
Server database and run some queries.
=20
I modified one of the queries, adding another table and field to the =
total:
=20
Before
-------------
select t1.plannbr_fi, t1.domain_ind, t2.fname, t2.lname, t3.fname, =
t3.lname,
t4.gso_code_alpha,
t5.notepad, t6.market_region_name
from (((((plan_base t1 LEFT OUTER JOIN staff_gso t2 ON
t1.id_sales_rep =3D t2.rep_id_idnty)
LEFT OUTER JOIN staff_gso t3 ON t1.id_acct_mgr =3D
t3.rep_id_idnty)
LEFT OUTER JOIN gso_offices t4 ON t1.gso_idnty =3D
t4.gso_idnty)
LEFT OUTER JOIN plan_notepad t5 ON t1.plannbr_idnty =3D
t5.plannbr_idnty)
LEFT OUTER JOIN regions_ops t6 ON t1.ops_region_idnty =
=3D
t6.ops_region_idnty)
where ...
=20
After
-------------
select t1.plannbr_fi, t1.domain_ind, t2.fname, t2.lname, t3.fname, =
t3.lname,
t4.gso_code_alpha,
t5.notepad, t6.market_region_name, t7.bus_name
from ((((((plan_base t1 LEFT OUTER JOIN staff_gso t2 ON
t1.id_sales_rep =3D t2.rep_id_idnty)
LEFT OUTER JOIN staff_gso t3 ON t1.id_acct_mgr =3D
t3.rep_id_idnty)
LEFT OUTER JOIN gso_offices t4 ON t1.gso_idnty =3D
t4.gso_idnty)
LEFT OUTER JOIN plan_notepad t5 ON t1.plannbr_idnty =3D
t5.plannbr_idnty)
LEFT OUTER JOIN regions_ops t6 ON t1.ops_region_idnty =
=3D
t6.ops_region_idnty)
-> LEFT OUTER JOIN specialty_risk_names t7 ON t1.id_tpa =3D
t7.srisk_idnty)
where ...
=20
After adding this line into the query, the script no longer ran, giving =
me
the following error:
bind_columns called with 9 refs when 10 needed. at =
C:/Perl/site/lib/DBI.pm
line
1787.
=20
Here's that section of code in DBI.pm:
=20
sub bind_columns {
my $sth =3D shift;
my $fields =3D $sth->FETCH('NUM_OF_FIELDS') || 0;
if ($fields <=3D 0 && !$sth->{Active}) {
return $sth->set_err(1, "Statement has no result columns to bind"
." (perhaps you need to successfully call execute first)");
}
# Backwards compatibility for old-style call with attribute hash
# ref as first arg. Skip arg if undef or a hash ref.
my $attr;
$attr =3D shift if !defined $_[0] or ref($_[0]) eq 'HASH';
=20
1787-> die "bind_columns called with ".@_." refs when $fields needed."
if @_ !=3D $fields;
my $idx =3D 0;
$sth->bind_col(++$idx, shift, $attr) or return
while (@_);
return 1;
}
Is there a max on the fields that can be passed?
=20
=20
=20
Kelly Logan
Rapid Technologies
(313) 645-4552
kel...@ra...
=20
|