FAQ
Hi,
I'm running a test to see whether certain criteria in a SELECT statement
return record or not. If I get a "no rows selected" from SQL then I want to
perform a specific action . But I don't how perform the test for "no rows
selected " ?

$sql = qq{SELECT RECORD FROM TABLE WHERE FIELD = ? } ;
$sth = $dbh->prepare($sql) ;
$sth->execute($variable) ;

while (@fetch = $sth4->fetchrow)
{
if ("no rows selected " .................?????? ) ### Don't know
how to test this
{
#perform my tasks
}

Regards,
Mark

Search Discussions

  • Reidy, Ron at Jan 28, 2005 at 4:55 pm
    If fetchrow() retrieves no data, the while loop terminates.

    -----------------
    Ron Reidy
    Lead DBA
    Array BioPharma, Inc.


    -----Original Message-----
    From: Mark Martin
    Sent: Friday, January 28, 2005 5:58 AM
    To: dbi-users@perl.org
    Subject: no rows selected


    Hi,
    I'm running a test to see whether certain criteria in a SELECT statement
    return record or not. If I get a "no rows selected" from SQL then I want to
    perform a specific action . But I don't how perform the test for "no rows
    selected " ?

    $sql = qq{SELECT RECORD FROM TABLE WHERE FIELD = ? } ;
    $sth = $dbh->prepare($sql) ;
    $sth->execute($variable) ;

    while (@fetch = $sth4->fetchrow)
    {
    if ("no rows selected " .................?????? ) ### Don't know
    how to test this
    {
    #perform my tasks
    }

    Regards,
    Mark


    This electronic message transmission is a PRIVATE communication which contains
    information which may be confidential or privileged. The information is intended
    to be for the use of the individual or entity named above. If you are not the
    intended recipient, please be aware that any disclosure, copying, distribution
    or use of the contents of this information is prohibited. Please notify the
    sender of the delivery error by replying to this message, or notify us by
    telephone (877-633-2436, ext. 0), and then delete it from your system.
  • Hardy Merrill at Jan 28, 2005 at 5:05 pm
    Mark, you would typically do something like this:

    my $ct_rows_processed = 0;
    while (@fetch = $sth->fetchrow) {
    $ct_rows_processed++;

    ### do stuff with a row of data ###

    } ### end while

    If ($ct_rows_processed = 0) {
    ### perform "no rows selected" tasks here ###
    }

    HTH.

    Hardy Merrill
    Mark Martin <mark.martin@nuim.ie> 01/28/05 7:58 AM >>>
    Hi,
    I'm running a test to see whether certain criteria in a SELECT
    statement
    return record or not. If I get a "no rows selected" from SQL then I
    want to
    perform a specific action . But I don't how perform the test for "no
    rows
    selected " ?

    $sql = qq{SELECT RECORD FROM TABLE WHERE FIELD = ? } ;
    $sth = $dbh->prepare($sql) ;
    $sth->execute($variable) ;

    while (@fetch = $sth4->fetchrow)
    {
    if ("no rows selected " .................?????? ) ### Don't
    know
    how to test this
    {
    #perform my tasks
    }

    Regards,
    Mark
  • Mark Martin at Jan 28, 2005 at 5:24 pm
    Thanks To All,
    good stuff here
    Mark
    At 12:05 28/01/2005 -0500, Hardy Merrill wrote:
    Mark, you would typically do something like this:

    my $ct_rows_processed = 0;
    while (@fetch = $sth->fetchrow) {
    $ct_rows_processed++;

    ### do stuff with a row of data ###

    } ### end while

    If ($ct_rows_processed = 0) {
    ### perform "no rows selected" tasks here ###
    }

    HTH.

    Hardy Merrill
    Mark Martin <mark.martin@nuim.ie> 01/28/05 7:58 AM >>>
    Hi,
    I'm running a test to see whether certain criteria in a SELECT
    statement
    return record or not. If I get a "no rows selected" from SQL then I
    want to
    perform a specific action . But I don't how perform the test for "no
    rows
    selected " ?

    $sql = qq{SELECT RECORD FROM TABLE WHERE FIELD = ? } ;
    $sth = $dbh->prepare($sql) ;
    $sth->execute($variable) ;

    while (@fetch = $sth4->fetchrow)
    {
    if ("no rows selected " .................?????? ) ### Don't
    know
    how to test this
    {
    #perform my tasks
    }

    Regards,
    Mark
  • Tony Adolph at Jan 31, 2005 at 10:34 am
    Hi folks,

    I have an application talking to an Oracle 8i DB via DBI. As a test we
    shutdown the network interface to see how the applcation responds and it
    hangs for minutes. What we'd like is to detect the problem pretty well
    immediately. How can this be done?

    Is there something similar to SQL_NET.EXPIRE_TIME to detect a dead server?

    Regards
    Tony

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-users @
categoriesperl
postedJan 28, '05 at 12:57p
activeJan 31, '05 at 10:34a
posts5
users4
websitedbi.perl.org

People

Translate

site design / logo © 2022 Grokbase