in reply to Can't call method "do" - DBI Troubles

Adding one more suggestion to this list of correct answers, you should probably trap some errors with . . .
my $dbh = DBI->connect($db, $username, $pass) || die $DBI->errstr();
and
my $dbh->do($sql) || die $dbh->errstr();
to catch any underlying problems with the connection process or underlying SQL execution.

Replies are listed 'Best First'.
Re: Re: Can't call method "do" - DBI Troubles
by Hero Zzyzzx (Curate) on Feb 03, 2003 at 17:58 UTC

    You can use the RaiseError option in the connect() method to automatically "status check" all calls to database functions, a nice little time saver. Note: you still have to status check the connect() method itself. . .

    my $dbh=DBI->connect($db,$username,$pass,{RaiseError => 1}) or die("Co +uldn't connect to database ".DBI::errstr);
    and the statement
    $dbh->do($sql);
    will automatically have status checking done for it, as well as any other calls to DBI.

    -Any sufficiently advanced technology is
    indistinguishable from doubletalk.