Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Can't crack a DBI Error:

by Daruma (Curate)
on Sep 24, 2002 at 14:50 UTC ( #200385=note: print w/ replies, xml ) Need Help??


in reply to Can't crack a DBI Error:

Greetings!!

I tested the following (using DBD::Oracle, mind you)

use strict; use DBI; use diagnostics; my $user = 'foo'; my $pass = 'bar'; my $dbh= DBI->connect( "dbi:Oracle:database", "$user", "$pass", ) or die "Can't connect to the database: $DBI::errstr\n"; my $sql = ' Select employee_id, employee_last_name, employee_grade from employees'; my $sth = $dbh->prepare($sql) or die "Can't prepare SQL statement: $DBI::errstr\n"; unless ($sth->execute) { fatal ("SQL query failed: " . $sth->errstr . "\n$sql"); } my $ref = $sth->fetchrow_arrayref() or die "Can't fetch: $DBI::errstr\n"; $sth->finish; print "@$ref[0] - @$ref[1] - @$ref[2]\n"; $dbh->disconnect;
If I remove the $sth->finish; line, It returns an error when attempting to disconnect against an open database handle... the fetch is still fetching... With the finish method, I do return just one row. Does that meet your need?

Beyond the fetchrow_array / finish vs. selectrow_array difference pointed out by Abstraction++, The code works fine for me.

Are you using strict, warning & diagnostics?? Is your code giving you feedback for every DBI package usage? (Have it die and give you feedback...

-Daruma


Comment on Re: Can't crack a DBI Error:
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://200385]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2014-04-19 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (478 votes), past polls