mysql中try的意思_什么是mysql對等的@ identity和@@error,以及如何在mysql中使用try catch...

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

我正在尋找mysql中的幾個全局變量,它們相當於sql server。

I want the whole list eg.

我要整張表。

Sql Server Equivalent

Sql Server等效

@@error ---

@ error - - -

@@Identity ---

@@Identity - - -

etc.

等。

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

基本上現在我想知道@error和@@identity的等價變量是什么。

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

但是如果你也能提供一些其他的變量,那將會很有幫助

1 个解决方案

#1

5

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

可以使用LAST_INSERT_ID()函數找到為當前連接生成的最后一個auto_increment值(即最后一個標識)。

About errors, not sure ; there doesn't seem to be any

關於錯誤,不確定;似乎沒有任何系統變量對應於最后一條錯誤消息。

There is a show errors statement :

有一個show errors語句:

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 : (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.

我認為應該有@@last_error_id和@last_error_message這樣的內容,但是我在當前手冊中找不到任何內容。

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.

這在目前是不可能的,根據我們所理解的錯誤處理將在5.2版本中得到改進,希望類似這樣的事情能夠成為可能。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值