Forum Moderators: coopster & phranque

Message Too Old, No Replies

fetchrow_arrayref failed: fetch() without execute()

It works, but I get an error message

         

salson

8:32 am on Sep 12, 2003 (gmt 0)



Hello.

Working on Linux+Perl, I must perform around 100 UPDATEs in a
MySQL table. It works, but I get continuously this message:

DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Mysql/Statement.pm
line 14, <F> line 96.

Does anybody have any experience? Thank you very much.

moltar

10:53 am on Sep 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Show us some of your code please.

salson

11:45 am on Sep 12, 2003 (gmt 0)



Ooops! You're right.

These three are executed about 100 times ('while'):
-------//-------------
$sql_query3 = "UPDATE my_table SET id='$id_field', name='$name_field', text='$text_field' WHERE id='$i'";
$query3 = $DB->query($sql_query3);
@array3 = $query3->fetchrow;
#There are no more SQL commands here
---------//--------------

Thank you very much.

moltar

1:56 pm on Sep 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Instead of
$DB->query($sql_query3);

try using

$DB->do($sql_query3);

salson

10:30 am on Sep 13, 2003 (gmt 0)



If I change it, I get this error message:
Mysql::do: Not defined in Mysql and not autoloadable (last try do) at testcode.pl line 82

Contents of
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi

auto DBD DBI.pm GD.pm Mysql perllocal.pod Win32
Bundle DBI GD HTML Mysql.pm qd.pl

What am I doing wrong?

PhraSEOlogy

4:22 pm on Sep 13, 2003 (gmt 0)

10+ Year Member



my $sql = "select col from table";
$sth = $dbh->prepare("$sql");
$sth->execute or die "$dbh->errstr\n";
$row = $sth->fetchrow_array;

I know this works. Not sure if you want to use this method but it work fine for me.

PhraSEOlogy

4:25 pm on Sep 13, 2003 (gmt 0)

10+ Year Member



Duh! wait a minute you are updating not selecting. Dont you just execute the command and that it! Whats the fetchrow for - you are not retrurning any data.

Perhaps you just need to execute the query and your done!

moltar

5:42 pm on Sep 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hahaha: good observation PhraSEOlogy! :)