MySQL Forums
Forum List  »  Stored Procedures

Re: How can I see warnings?
Posted by: Roland Bouman
Date: December 21, 2005 08:35AM

Just want to add, you can only view warnings immediately after the statement that caused them. In addition, SHOW WARNINGS shows the last warnings....AND/OR errors!

It seems trivial, but it is not as you will find out when you accidentally make a typo in your

SHOW WARNINGS

statement.

That happens to me alot, because I'm used to typing:

SHO

as short for SHOW (this is oracle sql*plus speak).
If you do that, a syntax error is given.
Now, the next SHOW WARNINGS that you do type corectly, will show the syntax error you caused by typing sho warnings rather than the warnings you are interested in.

A short example:


mysql> select 1 + 'a';
+---------+
| 1 + 'a' |
+---------+
| 1 |
+---------+
1 row in set, 1 warning (0.05 sec)

mysql> sho warnings
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sho w
arnings' at line 1

mysql> show warnings;
+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------
----------------+
| Level | Code | Message
|
+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------
----------------+
| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sho warn
ings' at line 1 |
+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------
----------------+
1 row in set (0.00 sec)


So, you see, we never get to see the warning that resulted from our initial statement.

Options: ReplyQuote


Subject
Views
Written By
Posted
2032
December 19, 2005 01:43AM
1287
December 19, 2005 03:00AM
Re: How can I see warnings?
1412
December 21, 2005 08:35AM
1292
December 21, 2005 09:30AM
1365
December 21, 2005 02:43PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.