Re: perl mysql DBI::db question
Shon wrote i am trying to write a program in perl and am getting a mysql error from my module. here is the error: DBI::db=HASH(0x294738)-disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at ./pop.pl line 124, GEN1 line 2. i think a finish statement is what i need, but i don't know how to exec it properly. here is the code loop that generates this message my $sql_check = $dbh-prepare(select user,password,prefs from users where username='$LNAME'); # I dont like the below die statement, it should exit gracefully. $sql_check-execute or die Can't connect to users table : $dbh-errstr; my ($t_user,$t_password,$t_prefs) = $sql_check-fetchrow_array(); # Here insert: $sql_check-finish(); $dbh-disconnect; if($debug_state) { print S: $t_user,$t_password,$t_prefs\n; } According to the DBI documentation, the finish statement is only needed if there are more rows available to fetch. Are you sure that your query can only return 1 row? Regards, Paul Paul B. van den Berg email: [EMAIL PROTECTED] Department of Social Pharmacy and Pharmacoepidemiology University Centre for Pharmacy tel:31-50-361 fax:31-50-3632772 Ant. Deusinglaan 1 9713 AV Groningen Netherlands - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: perl DBD::mysql question: SOLVED
colorparam0100,0100,0100/paramHello Jeremy, list, I asked: After a select .. insert .. the mysql client returns something like: Query OK, 11393 rows affected (0.47 sec) Records: 11393 Duplicates: 0 Warnings: 0 Is it possible in perl/DBI to fetch the count of duplicates and warnings, or even the time that the query took to process? Jeremy Zawodny answered: The timing is done by the client (I'm pretty sure), so you might want to use Perl's Time::HiRes module to figure out how much time has elapsed. Thanks for the suggestion. I also recall hearing that there are plan on the drawing board for making it easier to programmatically access warnings and errors after batch inserts. Well, if even Jeremy does not know an answer, it is time to RTFM.. I started with the description of the c-api, where I found mysql_info(), that returns the extra info as a string, if called immediately after a Load data infile, Insert .. select .., or Update... From there I read the DBD::mysql docs, where I found: $infoString = $dbh-{'info'}; this corresponds whith the c-api function. And yes, after a load data infile .. I found that: print $filenm, $dbh-{'info'}\n; returns: mydatafile, Records: 93337 Deleted: 0 Skipped: 0 Warnings: 93337 There must be some regex guru out there to convert this type of string to a proper hash, but for the moment I am quite happy with this solution. Regards, Paul nofill Paul B. van den Berg email: [EMAIL PROTECTED] Department of Social Pharmacy and Pharmacoepidemiology University Centre for Pharmacy tel:31-50-361 fax:31-50-3632772 Ant. Deusinglaan 1 9713 AV Groningen Netherlands - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
perl DBD::mysql question
Hello list, the regular mysql-client returns some useful information after batch-inserts like: Query OK, 11393 rows affected (0.47 sec) Records: 11393 Duplicates: 0 Warnings: 0 I can fetch the number of effected rows in perl/DBI with $sth-rows, but is it possible to fetch the count of duplicates and warnings, or even the time that the query took to process? Regards, Paul Paul B. van den Berg email: [EMAIL PROTECTED] Department of Social Pharmacy and Pharmacoepidemiology University Centre for Pharmacy tel:31-50-361 fax:31-50-3632772 Ant. Deusinglaan 1 9713 AV Groningen Netherlands - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: How can one validate a date in mysql ?
Dear Colleagues, How can one validate a date in mysql ? Kind regards, Pieter The simplest way that i know is: date_add(datestring, interval 0 day) This function wil return the correct date or NULL with months outside 1..12 and days outside 1..31. Here are some examples: select date_add('1999023', interval 0 day) - null select date_add('19990223', interval 0 day) -1999-02-23 select date_add('19990232', interval 0 day) - null select date_add('19990231', interval 0 day) -1999-03-03 Regards, Paul Paul B. van den Berg email: [EMAIL PROTECTED] Department of Social Pharmacy and Pharmacoepidemiology University Centre for Pharmacy tel:31-50-361 fax:31-50-3632772 Ant. Deusinglaan 1 9713 AV Groningen Netherlands - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php