Catching error Perl DBI

Catching error Perl DBI

am 25.02.2007 22:18:57 von Kiran Annaiah

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();

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/educat ion.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/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Catching error Perl DBI

am 26.02.2007 12:36:25 von Dave Howorth

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


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/educat ion.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/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org