On Thu, Nov 08, 2001 at 09:02:11PM -0600, Dave Sherohman wrote:
> #!/usr/bin/perl -wT
> 
> use strict;
> use DBI;
> 
> my $dbh = DBI->connect("dbi:Pg:host=SERVERNAME;dbname=DBNAME",
>                        "DBUSER", "DBPASSWORD")
>         || die "Failed to connect: $!\n";

$! doesn't return the real error here. use $DBI::errstr, DBI->errstr or
whatever style you like to call it with. (You can test this with suplying
PrintError => 0 to the attributes of the connect call.

Your version will just write:
Died at $0 line __LINE__

> my $qry = $dbh->prepare("select * from some_table");
> $qry->execute;

I'm just being pedantic here..sorry ;)

I'd rather have newcomers to DBI use the common (almost standard) name
of $sth instead of $qry. (Just for mantainability and when another
programmer has to look at the code.) I realize it's getting a bit
off-topic now.

> while (my @row = $qry->fetchrow_array) {
>   print @row;
> }
> 
> $dbh->do("delete from some_table");

-- 
  Thomas Eibner <http://thomas.eibner.dk/> DnsZone <http://dnszone.org/>
  mod_pointer <http://stderr.net/mod_pointer>