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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I installed DBD::mysql 4.018 and DBI 1.616 and ran the following based on your posting (note I had to invent $planname and substitute $dbname. Also I took out the fetch as it cannot work:

use strict; use DBI; my $h = DBI->connect('dbi:mysql:database=test', "xxx", "yyy"); eval { $h->do(q/drop table CUSTOMER_PLAN/); }; $h->do(<<EOT); CREATE TABLE `CUSTOMER_PLAN` ( `RowId` int(11) unsigned NOT NULL auto_increment, `Name` varchar(6) default NULL, `Credits` smallint(6) unsigned default NULL, `Price` decimal(8,2) default NULL, `Credit_Value` decimal(3,2) default NULL, `Status` char(1) default NULL, # A=Active, I=Inactive `Display_Order` char(3) default NULL, `Description` varchar(255) default NULL, PRIMARY KEY (RowId), KEY planname (Name), KEY descript (Description(15)), KEY dispord (Display_Order) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; EOT $h->do(q/INSERT INTO `CUSTOMER_PLAN` VALUES(1, 'Free', 0, 0.00, 0 +.75, 'A', '001', 'Try us out - receive 3 free recipes.')/); $h->do(q/INSERT INTO `CUSTOMER_PLAN` VALUES(2, 'Shine', 12, 9.75, 0 +.75, 'A', '002', 'Shine with a small introduction to Vibrant Healthy +Living.')/); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(3, 'Seeker', 35, 18.75, 0 +.75, 'A', '003', '<i>-noun.</i> An adventurous person who is seeking +new experiences and new information to create a higher level of under +standing and enlightenment.')|); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(4, 'Sage', 60, 47.00, 0 +.75, 'A', '004', '<i>-noun.</i> A generous, lively person on the jour +ney for the possession of wisdom and experience. This person is energ +etic, vibrant and famed for health and wisdom.')|); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(5, 'Guru', 120, 89.00, 0 +.75, 'A', '005', '<i>-noun.</i> A divine teacher. This person has vas +t knowledge and practices vibrant living while sharing with their com +munity to create a greater understanding and manifestation of truth a +nd beauty.')|); sub db_err { my ($pmsg, $psql, $perrnum, $perrstr) = @_; print "<p>There was a problem: $pmsg.</p>\n"; print "<p><i>Attempted command:</i> $psql</p>\n"; print "<p><i>Error:</i> $perrnum - $perrstr</p>\n"; } my $dbname = 'test'; my $planname = 'Free'; my $sql = "SELECT DCredits, Price, Description FROM $dbname.CUSTOMER_P +LAN WHERE Name='$planname'"; my $sqlh = $h->prepare($sql) || db_err("preparing statement handle", $ +sql, $DBI::err, $DBI::errstr); $sqlh->execute || db_err("executing query", $sql, $DBI::err, $DBI::err +str); #####while (@row = $sqlh->fetchrow_array()) #####{ ##### ($credits, $price, $descript) = @row; ##### # process the data on each loop here #####} #####$sqlh->finish; $h->disconnect;

It fails with:

DBD::mysql::st execute failed: Unknown column 'DCredits' in 'field lis +t' at /home/martin/930402.pl line 45. <p>There was a problem: executing query.</p> <p><i>Attempted command:</i> SELECT DCredits, Price, Description FROM +test.CUSTOMER_PLAN WHERE Name='Free'</p> <p><i>Error:</i> 1054 - Unknown column 'DCredits' in 'field list'</p>

When I rerun it with DBI_TRACE=15 I get the following near the end:

-> prepare for DBD::mysql::db (DBI::db=HASH(0x9f482a0)~0x9f483c0 ' +SELECT DCredits, Price, Description FROM test.CUSTOMER_PLAN WHERE Nam +e='Free'') thr#9dd4008 New 'DBI::st' (for DBD::mysql::st, parent=DBI::db=HASH(0x9f483c0), + id=undef) dbih_setup_handle(DBI::st=HASH(0x9f48180)=>DBI::st=HASH(0x9e50408) +, DBD::mysql::st, 9ece010, Null!) dbih_make_com(DBI::db=HASH(0x9f483c0), 9f3e808, DBD::mysql::st, 25 +2, 0) thr#9dd4008 dbih_setup_attrib(DBI::st=HASH(0x9e50408), Err, DBI::db=HASH(0x9f4 +83c0)) SCALAR(0x9ecdf30) (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), State, DBI::db=HASH(0x9 +f483c0)) SCALAR(0x9ecdfb0) (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), Errstr, DBI::db=HASH(0x +9f483c0)) SCALAR(0x9ecdf70) (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), TraceLevel, DBI::db=HAS +H(0x9f483c0)) 0 (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), FetchHashKeyName, DBI:: +db=HASH(0x9f483c0)) 'NAME' (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), HandleSetErr, DBI::db=H +ASH(0x9f483c0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), HandleError, DBI::db=HA +SH(0x9f483c0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), ReadOnly, DBI::db=HASH( +0x9f483c0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), Profile, DBI::db=HASH(0 +x9f483c0)) undef (not defined) -> dbd_st_prepare MYSQL_VERSION_ID 50083, SQL statement: SELECT DC +redits, Price, Description FROM test.CUSTOMER_PLAN WHERE Name='Free' >- dbd_st_free_result_sets <- dbd_st_free_result_sets RC -1 <- dbd_st_free_result_sets >count_params statement SELECT DCredits, Price, Description FROM test. +CUSTOMER_PLAN WHERE Name='Free' <- dbd_st_prepare <- prepare= DBI::st=HASH(0x9f48180) at /home/martin/930402.pl line + 44 >> execute DISPATCH (DBI::st=HASH(0x9f48180) rc1/1 @1 g0 ima10 +41 pid#19440) at /home/martin/930402.pl line 45 -> execute for DBD::mysql::st (DBI::st=HASH(0x9f48180)~0x9e50408) +thr#9dd4008 -> dbd_st_execute for 09ece030 >- dbd_st_free_result_sets <- dbd_st_free_result_sets RC -1 <- dbd_st_free_result_sets mysql_st_internal_execute MYSQL_VERSION_ID 50083 >parse_params statement SELECT DCredits, Price, Description FROM test. +CUSTOMER_PLAN WHERE Name='Free' --> do_error Unknown column 'DCredits' in 'field list' error 1054 recorded: Unknown + column 'DCredits' in 'field list' <-- do_error IGNORING ERROR errno 0 <- dbd_st_execute returning imp_sth->row_num 18446744073709551614 !! ERROR: 1054 'Unknown column 'DCredits' in 'field list'' (err#0) <- execute= undef at /home/martin/930402.pl line 45 DBD::mysql::st execute failed: Unknown column 'DCredits' in 'field lis +t' at /home/martin/930402.pl line 45. -> $DBI::err (*) FETCH from lasth=HASH <- $DBI::err= 1054 -> $DBI::errstr (&) FETCH from lasth=HASH >> DBD::mysql::st::errstr <- $DBI::errstr= 'Unknown column 'DCredits' in 'field list''

What does your trace output look like on the failing machine?


In reply to Re^3: DBI fails to return an error code by mje
in thread DBI fails to return an error code by djten

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (14)
    As of 2015-07-30 18:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (273 votes), past polls