Catching error Perl DBI

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( [at] 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 ( [at] 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 [at] m .gmane.org
Kiran Annaiah [ So, 25 Februar 2007 22:18 ] [ ID #1639653 ]

Re: Catching error Perl DBI

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( [at] 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 ( [at] 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 [at] m .gmane.org
Dave Howorth [ Mo, 26 Februar 2007 12:36 ] [ ID #1640427 ]
Datenbanken » gmane.comp.db.mysql.perl » Catching error Perl DBI

Vorheriges Thema: How to get Perl version for AIX using gcc compiler to avoidproblems installing DBD::mysql without cc
Nächstes Thema: foreign_key_info() implementation