fetchrow not proceeding beyond 9th record

D

dn_perl

I am trying to fetch rows using $sth->fetchrow.
If I run my sql query from 'sqlplus' prompt, it returns 58 unique
records. But if I do :

while ($sth->fetchrow())

the loop is terminated after processing only 9 (not 58) records.

Why could this be happening? Is there any variable associated with
Perl DBI which is set to 9 and fetches only 9 rows by default.
If the number was 8 or 16, that would be less of a surprise.
But I am unable to make out while the loop exits too early
and why it exists after fetching 9 records.

Please advise.
 
T

Thomas Kratz

I am trying to fetch rows using $sth->fetchrow.
If I run my sql query from 'sqlplus' prompt, it returns 58 unique
records. But if I do :

while ($sth->fetchrow())

the loop is terminated after processing only 9 (not 58) records.

Why could this be happening? Is there any variable associated with
Perl DBI which is set to 9 and fetches only 9 rows by default.
If the number was 8 or 16, that would be less of a surprise.
But I am unable to make out while the loop exits too early
and why it exists after fetching 9 records.

Please advise.

First advice: Please read the posting guidelines and post real code -
a minimal example - that shows the problem.

A DBI statement handle has no fetchrow() method! There are a few that
begin with "fetchrow" though.

And there are no restrictions on the number of returned rows from a
select statement.

Second advice: Please read the docs (perldoc DBI).
When fetching a row of data from a statement handle fails, you can use
the $sth->err() method to check the error. Also have a look at the
trace method of the database handle.

And tell us what perl and DBI version you are running.

Thomas
 
G

Gregory Toomey

It was a dark and stormy night, and (e-mail address removed) managed to scribble:
I am trying to fetch rows using $sth->fetchrow.
If I run my sql query from 'sqlplus' prompt, it returns 58 unique
records. But if I do :

while ($sth->fetchrow())

the loop is terminated after processing only 9 (not 58) records.

Why could this be happening? Is there any variable associated with
Perl DBI which is set to 9 and fetches only 9 rows by default.
If the number was 8 or 16, that would be less of a surprise.
But I am unable to make out while the loop exits too early
and why it exists after fetching 9 records.

Please advise.

Well, it shouldn't!

I suggest posting the code that causes the problem. Are there any variables used in the SQL statement. Are you SURE the statements are the same. Are you checking DBI return codes?

Note that some databases like Oracle (and possibly mysql with Innodb tables) have "read consistency", allowing two users to see different data. Make sure you are doing commits.

gtoomey
 
C

ctcgag

I am trying to fetch rows using $sth->fetchrow.
If I run my sql query from 'sqlplus' prompt, it returns 58 unique
records. But if I do :

while ($sth->fetchrow())

the loop is terminated after processing only 9 (not 58) records.

Why could this be happening?

I don't know what fetchrow is. Is it a deprecated synonym for
fetchrow_array?

If so, then as soon as you return a false value (0,empty string,etc.) your
loop will test false and exit.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top