On 2009-07-28 09:19:05 -0700, David Goodman wrote:
> I suggest that you check to see if the string $DBI::errstr is empty
> rather than just whether the 'do' function executed correctly. 
> 
> It seems that the SQL is correctly submitted from the DBI side but the
> database server actually produces an error message.

The server does not produce an error message. It only produces a
warning. You can see the same behaviour in the mysql command line
client:


    mysql> insert into foo(name, age) values('foo2', 'bar2');
    Query OK, 1 row affected, 1 warning (0.00 sec)

The query is ok, there is no error, but 1 warning.

    mysql> show warnings;
    
+---------+------+-----------------------------------------------------------+
    | Level   | Code | Message                                                  
 |
    
+---------+------+-----------------------------------------------------------+
    | Warning | 1366 | Incorrect integer value: 'bar2' for column 'age' at row 
1 | 
    
+---------+------+-----------------------------------------------------------+
    1 row in set (0.00 sec)


This is MySQL specific, so you have to check the documentation of
DBD::mysql. And sure enough, the first occurrence of "warning" is:

       mysql_warning_count
           The number of warnings generated during execution of the SQL
           statement.

However, the DBI does know about warnings and information, too:

       A driver may return 0 from err() to indicate a warning condition after
       a method call. Similarly, a driver may return an empty string to
       indicate a ’success with information’ condition. In both these cases
       the value is false but not undef. The errstr() and state() methods may
       be used to retrieve extra information in these cases.


        hp

-- 
   _  | Peter J. Holzer    | Auf jedem Computer sollte der Satz Ludwigs II
|_|_) | Sysadmin WSR       | eingeprägt stehen: "Ein ewig Rätsel will ich
| |   | h...@wsr.ac.at      | bleiben, mir und andern."
__/   | http://www.hjp.at/ |    -- Wolfram Heinrich in desd

Attachment: signature.asc
Description: Digital signature

Reply via email to