views:

38

answers:

1

I am looking for few global variable in mysql which are equivalent of sql server.

I want the whole list eg.

Sql Server Equivalent

@@error ---

@@Identity ---

etc.

Basically right now I want to know what are the equivalent variable of @@error and @@identity.

But it will be helpfull if u could provide some other variable also

+2  A: 

The last auto_increment value (i.e. the last identity) generated for the current connection can be found using the LAST_INSERT_ID() function.


About errors, not sure ; there doesn't seem to be any system variable that corresponds to the last error message.

There is a show errors statement :

mysql> select a from b;
ERROR 1046 (3D000): No database selected

mysql> show errors;
+-------+------+----------------------+
| Level | Code | Message              |
+-------+------+----------------------+
| Error | 1046 | No database selected | 
+-------+------+----------------------+
1 row in set (0,00 sec)

But not sure how you can use this result...


After searching a bit more, I found out this thread : Getting the last error message, which says (quoting) :

I think there should be something like @@last_error_id and @@last_error_message, but I can`t find anything in the current manual.

And the first answer states (quoting) :

This isn't possible currently, from what we understand error handling will be improved in version 5.2 and hopefully something like this may be possible.

Pascal MARTIN