Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: DBI::mysql fetch() without execute() PROBLEM

by peppiv (Curate)
on Jan 22, 2002 at 01:01 UTC ( #140491=note: print w/replies, xml ) Need Help??


in reply to Re: DBI::mysql fetch() without execute() PROBLEM
in thread DBI::mysql fetch() without execute() PROBLEM

The  die $dbh->errstr if $dbh->errstr; gives me the same problem (fetch() without execute ()).

The die $! if $! returns nothing.

Replies are listed 'Best First'.
Re^3: DBI::mysql fetch() without execute() PROBLEM
by Anonymous Monk on Jan 21, 2021 at 22:03 UTC

    I had a similar problem. Looks like that when a script runs fetchrow_array and there is no more lines to be returned, DBD kill the cursor and , so, any try to access methods or attributes of the statement handle ($sth) will raise the error "fetch() without execute()".

    I solved my problem with a conditional :

    $sth->execute() or die "Error executing [$sqlcmd] : " . $dbh->errstr; $end_fetch = 0; do { if (! $end_fetch) { ($key_col, $col1, $col2, $col3) = $sth->fetchrow_array; if (! defined $key_col) { $end_fetch = 1; } } ... } while ($some_condition);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://140491]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2021-06-19 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (91 votes). Check out past polls.

    Notices?