Scott R. Godin writes:
> the absolute neatest trick I've seen with this, that is so totally
> perlish it defies description.. you stare at it for a bit and suddenly
> all becomes clear.
>
> $sth->execute
> or die("Cannot Execute SQL Statement: ", $sth->errstr(), "\n");
>
> my $rows = $sth->rows;
> # only expecting one row for a unique ID . this should NEVER happen.
> safe_error("invalid number of rows returned from database ($rows) for
> ID $id")
> if $rows > 1;
> # although this might...
> safe_error("no match in database for ID $id")
> if $rows < 1;
Be careful here!
Most DBI drivers will return -1 for $sth->rows() for a SELECT query.
In the case of DBD::Sybase $h->rows() will return the correct number
of rows only *after* all the rows have been fetched.
See the DBI docs for details.
Michael
--
Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
[EMAIL PROTECTED] - [EMAIL PROTECTED]
International Sybase User Group - http://www.isug.com