fetchrow not proceeding beyond 9th record

Discussion in 'Perl Misc' started by dn_perl@hotmail.com, Nov 12, 2003.

  1. Guest

    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.
    , Nov 12, 2003
    #1
    1. Advertising

  2. Thomas Kratz Guest

    wrote:

    > 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
    Thomas Kratz, Nov 12, 2003
    #2
    1. Advertising

  3. It was a dark and stormy night, and 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
    Gregory Toomey, Nov 12, 2003
    #3
  4. Guest

    () wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service New Rate! $9.95/Month 50GB
    , Nov 13, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joan Maceachern
    Replies:
    0
    Views:
    386
    Joan Maceachern
    Jul 28, 2005
  2. Luc Vantroys
    Replies:
    8
    Views:
    129
    Eric Armstrong
    Aug 15, 2006
  3. Luc Vantroys
    Replies:
    1
    Views:
    86
    N Okia
    Aug 5, 2006
  4. superfly2

    DBI.pm fetchrow() issue

    superfly2, Sep 18, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    86
    Ryan Shondell
    Sep 18, 2003
  5. 1kHz
    Replies:
    2
    Views:
    99
    Rich Hephner
    May 17, 2005
Loading...

Share This Page