Re: Catching error Perl DBI

Dave Howorth <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Organization MRC Centre for Protein Engineering
Message-ID <[email protected]>
Kiran Annaiah wrote:
> Hello all,
> 
> Am a newbie to Perl DBI. I am trying to figure out how to catch an error
> when the Select statement returns no results.
> Not sure if i am doing it right...
> 
> My query looks like this....
> 
> my $cid_query = qq{Select pedpath from chipid_pedpath where chipid=?};
> my $sth_cid = $dbh->prepare($cid_query);
> 
> 
>    for(@chipids){
>        $sth_cid->bind_param( 1, $_, SQL_INTEGER);
> 
>        my $rv = $sth_cid->execute();

I think you need to read the documentation for execute, which describes
the return value
<http://search.cpan.org/~timb/DBI-1.54/DBI.pm#execute>

You might also check that for fetchrow_array which describes how to tell
when there are no more arrays.

Cheers, Dave

>        if($rv != 0){
>            print "no row returned -> ". $sth_cid->fetchrow_array."\n";
>        }
>        else{
>           print "pushing into array";
>           push (@row, $sth_cid->fetchrow_array);
>       }
>   }
> 
> 
> 
> Any suggestions would help:)
> 
> thank you
> k
> -kiran
> 
> _________________________________________________________________
> Want a degree but can't afford to quit? Top school degrees online - in
> as fast as 1 year
> http://forms.nextag.com/goto.jsp?url=/serv/main/buyer/education.jsp?doSearch=n&tm=y&search=education_text_links_88_h288c&s=4079&p=5116
> 
> 
> 


-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.