On 1 Feb 2002, at 10:14, Michael A Chase wrote: > Comments below. > -- > Mac :}) > ** I normally forward private questions to the appropriate mail list. > ** Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.htm > Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring > and he eats fish for an age. ----- Original Message ----- From: > <[EMAIL PROTECTED]> To: "Craig Sharp" <[EMAIL PROTECTED]> Cc: > <[EMAIL PROTECTED]> Sent: Friday, February 01, 2002 01:39 Subject: > Re: Not found subroutine > > > > Craig, (but it's more a question to and Tim and Mac) > > > > > I need to be able to determine if a value is not found within a > > > database and if so, report that the data and or row is not > > > available back to the browser. > > > > > > Here is my script that I am using to retrieve the data: > > > > > > >>>>>> SNIP >>>>>>>>> > > > > > > $dbh = DBI->connect("DBI:Informix:domain", > > > { > > > RaiseError => 1, > > > AutoCommit => 0 > > > } > > > ); > > > > > > $sth = $dbh->prepare("update reg_info set active = ? where > > > domain_name = > ?"); > > > $sth->bind_param( 1, $postInputs{'active'} ); > > > $sth->bind_param( 2, $postInputs{'domain_name'} ); > > > $sth->execute(); > > > > 1. Besides that the above should be in an eval block anyways, is it > > a trappable (via eval and die/RaiseError) error at all if > > domain_name does not exist? Or is it just a 'normal' situation with > > just zero rows updated? Or is this database or driver specific? > > An eval{} block is only useful if you want to continue executing even > if there is an error. You probably do if you need to send a response > back to a browser. > > Not finding a domain name in the table is not an 'error'. It is just > a condition of the data. To see if that happened, you can check the > value returned by $sth-execute() or check $sth->rows. It is not > database or driver specific. > > > 2. Isn't this exactly the situation $sth->rows is meant for? For > > something like > > Yes it is. The problem with $sth->rows comes when someone trys to use > it with SELECT. >
Thanks Bodo
