dbi_RaiseError_vs_die

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.




Subject: RE: fetchrow_array within while loop problem
From: Doug Wilson <dougw@safeguard.net>
Date: Thu, 8 Jun 2000 14:26:24 -0700 


Ilya Sterin <ideas_pc@usa.com> wrote:

> >Can anyone help me.  When I run this script it seems to
> >execute fine when I fetch each row separately, but when I
> >put in a while loop it dies with no error messages.  The
> >program just stops executing at that point.  I couldn't
> >fit the whole script on here but the use DBI; and the
> >$stmt assignment are all there before the connect.  For
> >some reason it doesn't like the while loop.
> >
> >$db = DBI->connect($data_source, $loginID, $password, 
> 'Oracle', {AutoCommit
> >=> 0, RaiseError => 1}) or die $DBI::errstr;
> >$db->quote($stmt);
> >$sth = $db->prepare($stmt)
> >or die $DBI::errstr;
> >$sth->execute() or die $DBI::errstr;
> >
> >@code_value_list = ();
> >@code_description_list = ();
> >$number = 0;
> >
> >while(($code_value, $code_description) = 
> $sth->fetchrow_array() or die
> >$DBI::errstr) {
> >$code_value =~ s/ *$//;
> >$code_description =~ s/ *$//;
> >$code_value_list[$number] = $code_value;
> >$code_description_list[$number] = $code_description;
> >$number = $number + 1;
> >
> >}


Alan Sparks" <asparks@cpd.harris.com> wrote:

> I think you have major problems with the "or die" stuff 
> you're enclosing in
> the while condition.  Highly suggest you remove this and test again.

Ilya Sterin [mailto:ideas_pc@usa.com] wrote:

> I've ran the script without it too earlier, it did the
> same thing.  I thought I would add this to see the
> problem, it then printed the error "died at line #96".  So
> either way it died at that point.  Thanks for the reply,
> does any one have any more suggestions??

With the 'RaiseError' set, you should not need the 'or die'
clauses on the DBI related lines; the die's would
not even be executed in that case. Also, the connect statement
has 'Oracle' in between the password and the attribute arguments;
is that a problem, or just something I don't know about?

===

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu