Maybe the (Sybase) database driver doesn't like only half-fetching the resultset? Have you tried fetching the complete resultset and then issuing your second query? Something like:
my $prod_dbh = DBI->connect_cached('DBI:Sybase:database','web_','web')
+ || die "Couldn't connect to DB!\n" . DBI->errstr;
my $parent_sth = $prod_dbh->prepare_cached('select * from table where
+id = ?');
$parent_sth->bind_param(1,$id);
$parent_sth->execute();
my $parent_data = $parent_sth->fetchall_arrayref();
...
my $child_sth = $prod_dbh->prepare_cached('select * from table2 where
+id = ?');
$child_sth->bind_param(1,$parent_data[0]);
$child_sth->execute();
my $child_data = $child_sth->fetchall_arrayref();
print Dumper($child_data->[0]);
Of course, with your statement handles named $parent_data and $child_data, maybe you are trying to fetch data in a parent/child relationship where you instead could be doing an SQL JOIN between the two tables to issue only a single query?
select
parent.*
, child.*
from table parent
join table2 child on (parent.id=child.id)
where parent.id = ?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|