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

Re^2: DBI Fetches don't work

by ido50 (Scribe)
on Nov 12, 2004 at 15:10 UTC ( [id://407376]=note: print w/replies, xml ) Need Help??


in reply to Re: DBI Fetches don't work
in thread DBI Fetches don't work

Well I've read it, but it doesn't really match my problem. That node talks about using select routines with a pre-prepared statement handle. My $sth is fresh...

-------------------------
Live fat, die young

Replies are listed 'Best First'.
Re^3: DBI Fetches don't work
by mpeppler (Vicar) on Nov 12, 2004 at 15:26 UTC
    Turn on DBI tracing (DBI->trace(4) or higher) to see what may be going on. Check to see if your program is dying due a signal of some sort (SEGV, or other) - enable core dumps (ulimit -c unlimited) to try to get a core that you can use to get a stack trace (if a core is generated).

    Michael

      Well, I've ran the following test code with tracing enabled. The code is:

      #!/usr/bin/perl -w package TEST; BEGIN { $|=1; use CGI::Carp('fatalsToBrowser'); } ### Load Required Modules ### use strict; use DBI; use CGI qw/:standard/; ### Variable init. ### $TEST::CGI = new CGI; print $TEST::CGI->header; my $db = "/hsphere/local/home/katom/bnei-yehuda.co.il/texts/SheepWool/ +test.db"; my $log = "/hsphere/local/home/katom/bnei-yehuda.co.il/texts/SheepWool +/test.log"; unlink $log if -e $log; my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","", { RaiseError => +1 }) or die $DBI::errstr; DBI->trace(6, $log); print "Preparing and executing CREATE TABLE statement.<br>"; my $sth = $dbh->prepare(" CREATE TABLE users ( id INTEGER NOT NULL, name VARCHAR(128) ) " ); $sth->execute; print "Preparing and executing INSERT statement.<br>"; my $username = $dbh->quote("ido50"); $sth = $dbh->prepare(" INSERT INTO users VALUES (1, $username) "); $sth->execute; print "Preparing and executing a SELECT statement.<br>"; $sth = $dbh->prepare(" SELECT * FROM users WHERE id = 1 "); $sth->execute; my @row = $sth->fetchrow_array; $sth->finish; $dbh->disconnect; exit;
      The output from trace() is as follows (I don't see nothing out of order, though I don't have any experience with tracing):

      DBI 1.28-nothread dispatch trace level set to 6 -> prepare for DBD::SQLite::db (DBI::db=HASH(0x81e8f78)~0x81e89a4 +' CREATE TABLE users ( id INTEGER NOT NULL, name VARCHAR(128) ) ') New DBI::st (for DBD::SQLite::st, parent=DBI::db=HASH(0x81e89a4), +id=) dbih_setup_handle(DBI::st=HASH(0x81d7478)=>DBI::st=HASH(0x805b270) +, DBD::SQLite::st, 81d7484, Null!) dbih_make_com(DBI::db=HASH(0x81e89a4), DBD::SQLite::st, 124) dbih_setup_attrib(DBI::st=HASH(0x805b270), Err, DBI::db=HASH(0x81e +89a4)) SCALAR(0x80fc7b4) (already defined) dbih_setup_attrib(DBI::st=HASH(0x805b270), State, DBI::db=HASH(0x8 +1e89a4)) SCALAR(0x80fc79c) (already defined) dbih_setup_attrib(DBI::st=HASH(0x805b270), Errstr, DBI::db=HASH(0x +81e89a4)) SCALAR(0x80fc7cc) (already defined) dbih_setup_attrib(DBI::st=HASH(0x805b270), Debug, DBI::db=HASH(0x8 +1e89a4)) 0 (already defined) dbih_setup_attrib(DBI::st=HASH(0x805b270), FetchHashKeyName, DBI:: +db=HASH(0x81e89a4)) 'NAME' (already defined) dbih_setup_attrib(DBI::st=HASH(0x805b270), HandleError, DBI::db=HA +SH(0x81e89a4)) undef (not defined) sqlite trace: prepare statement: CREATE TABLE users ( id INTEGER NOT NULL, name VARCHAR(128) ) <- prepare= DBI::st=HASH(0x81d7478) at /path/to/testadmin.pl line +29 -> execute for DBD::SQLite::st (DBI::st=HASH(0x81d7478)~0x805b270) sqlite trace: Execute returned 0 cols <- execute= '0E0' at /path/to/testadmin.pl line 36 -> quote in DBD::_::db for DBD::SQLite::db (DBI::db=HASH(0x81e8f78 +)~0x81e89a4 'ido50') <- quote= ''ido50'' at /path/to/testadmin.pl line 39 -> prepare for DBD::SQLite::db (DBI::db=HASH(0x81e8f78)~0x81e89a4 +' INSERT INTO users VALUES (1, 'ido50') ') New DBI::st (for DBD::SQLite::st, parent=DBI::db=HASH(0x81e89a4), +id=) dbih_setup_handle(DBI::st=HASH(0x8151ae8)=>DBI::st=HASH(0x81d74fc) +, DBD::SQLite::st, 8151ad0, Null!) dbih_make_com(DBI::db=HASH(0x81e89a4), DBD::SQLite::st, 124) dbih_setup_attrib(DBI::st=HASH(0x81d74fc), Err, DBI::db=HASH(0x81e +89a4)) SCALAR(0x80fc7b4) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d74fc), State, DBI::db=HASH(0x8 +1e89a4)) SCALAR(0x80fc79c) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d74fc), Errstr, DBI::db=HASH(0x +81e89a4)) SCALAR(0x80fc7cc) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d74fc), Debug, DBI::db=HASH(0x8 +1e89a4)) 0 (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d74fc), FetchHashKeyName, DBI:: +db=HASH(0x81e89a4)) 'NAME' (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d74fc), HandleError, DBI::db=HA +SH(0x81e89a4)) undef (not defined) sqlite trace: prepare statement: INSERT INTO users VALUES (1, 'ido50') <- prepare= DBI::st=HASH(0x8151ae8) at /path/to/testadmin.pl line +40 <> DESTROY ignored for outer handle DBI::st=HASH(0x81d7478) (inner + DBI::st=HASH(0x805b270)) -> DESTROY for DBD::SQLite::st (DBI::st=HASH(0x805b270)~INNER) <- DESTROY= undef at /path/to/testadmin.pl line 43 dbih_clearcom (h 0x81d7478, com 0x81ce180): FLAGS 0x191: COMSET Warn RaiseError PrintError TYPE 3 PARENT DBI::db=HASH(0x81e89a4) KIDS 0 (0 Active) IMP_DATA undef in 'DBD::SQLite::st' NUM_OF_FIELDS 0 NUM_OF_PARAMS 0 dbih_clearcom 0x81d7478 (com 0x81ce180, type 3) done. -> execute for DBD::SQLite::st (DBI::st=HASH(0x8151ae8)~0x81d74fc) sqlite trace: Execute returned 0 cols <- execute= 1 at /path/to/testadmin.pl line 43 -> prepare for DBD::SQLite::db (DBI::db=HASH(0x81e8f78)~0x81e89a4 +' SELECT * FROM users WHERE id = 1 ') New DBI::st (for DBD::SQLite::st, parent=DBI::db=HASH(0x81e89a4), +id=) dbih_setup_handle(DBI::st=HASH(0x81d7544)=>DBI::st=HASH(0x81d7538) +, DBD::SQLite::st, 81d7550, Null!) dbih_make_com(DBI::db=HASH(0x81e89a4), DBD::SQLite::st, 124) dbih_setup_attrib(DBI::st=HASH(0x81d7538), Err, DBI::db=HASH(0x81e +89a4)) SCALAR(0x80fc7b4) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d7538), State, DBI::db=HASH(0x8 +1e89a4)) SCALAR(0x80fc79c) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d7538), Errstr, DBI::db=HASH(0x +81e89a4)) SCALAR(0x80fc7cc) (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d7538), Debug, DBI::db=HASH(0x8 +1e89a4)) 0 (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d7538), FetchHashKeyName, DBI:: +db=HASH(0x81e89a4)) 'NAME' (already defined) dbih_setup_attrib(DBI::st=HASH(0x81d7538), HandleError, DBI::db=HA +SH(0x81e89a4)) undef (not defined) sqlite trace: prepare statement: SELECT * FROM users WHERE id = 1 <- prepare= DBI::st=HASH(0x81d7544) at /path/to/testadmin.pl line +46 <> DESTROY ignored for outer handle DBI::st=HASH(0x8151ae8) (inner + DBI::st=HASH(0x81d74fc)) -> DESTROY for DBD::SQLite::st (DBI::st=HASH(0x81d74fc)~INNER) <- DESTROY= undef at /path/to/testadmin.pl line 50 dbih_clearcom (h 0x8151ae8, com 0x81cce80): FLAGS 0x191: COMSET Warn RaiseError PrintError TYPE 3 PARENT DBI::db=HASH(0x81e89a4) KIDS 0 (0 Active) IMP_DATA undef in 'DBD::SQLite::st' NUM_OF_FIELDS 0 NUM_OF_PARAMS 0 dbih_clearcom 0x8151ae8 (com 0x81cce80, type 3) done. -> execute for DBD::SQLite::st (DBI::st=HASH(0x81d7544)~0x81d7538) sqlite trace: Execute returned 2 cols sqlite trace: exec ok - 0 rows, 2 cols <- execute= '0E0' at /path/to/testadmin.pl line 50 -> fetchrow_array for DBD::SQLite::st (DBI::st=HASH(0x81d7544)~0x8 +1d7538) sqlite trace: numFields == 2, nrow == 0 dbih_setup_fbav for 2 fields => 0x81d74f0
      Any thoughts?
      Thanks.

      -------------------------
      Live fat, die young

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found