in reply to Re: Testing to see if a MySQL query is true
in thread Testing to see if a MySQL query is true

The phrase "in the first iteration of your while loop" made me think of something other than the way I would do it, but the idea is at least very similar. Like this:

$sth->execute(); my @ary= $sth->fetchrow_array(); if( @ary ) { open(MAIL,"|$mailprog -t"); print MAIL ... do { print MAIL join ("\t", @ary), "\n"; } while( @ary = $sth->fetchrow_array() ); print MAIL "\nEND OF SCHEDULED EVENTS!\n"; close(MAIL); } $sth->finish();

        - tye (at least very similar to "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Testing to see if a MySQL query is true
by runrig (Abbot) on Oct 23, 2002 at 01:04 UTC
    I'm going to go out on a limb and assume akm2 doesn't have a million appointments a day, in which case we may as well use selectall_arrayref:
    my $results = $dbh->selectall_arrayref($sql_statement); if (@$results) { open... print... print ... join("\t", @$_),"\n" for @$results; print... close... }