Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » UltraLite - M-Business Anywhere 编程 » UltraLite for M-Business Anywhere API 参考 » Connection 类

 

getLastIdentity 方法

返回最近使用的标识值。

语法
UInt64 getLastIdentity()
注释

此函数等同于以下 SQL 语句:

  SELECT @@identity

此函数在全局自动增量列的上下文中特别有用。返回值是数据库数据类型为 UNSIGNED BIGINT 的无符号 64 位整数。由于此语句仅确定最近指派的缺省值,所以您应在执行插入语句后尽快检索此值,以避免得到虚假结果。

有时,单个插入语句可能会包括类型为全局自动增量的多个列。在这种情况下,返回值是生成的缺省值之一,但没有可靠的方法能确定是哪一个。建议在设计数据库和编写插入语句时,应避免这种情况。