Powerbuilder 从datawindow 获取自增长字段的数据

本文介绍了SQL Server数据库接口新增的DBParm AtAtIdentity参数,用于在DataWindow更新请求中获取新插入行的身份值。该参数提供两种方式获取身份值,一种是默认的SELECT MAX(IDENTCOL)语法,另一种是使用SELECT @@identity。AtAtIdentity=1可以在并发更新时提供更准确的结果,但可能不适用于包含触发器的表。此参数可通过设置SQLCA.dbParm动态调整,但不能在MSS数据库配置对话框中设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

设置SQLCA.dbParm = "AtAtIdentity = '1'"

Database Connectivity Information
==============================================

New DBParm Support
==================
Support for a new DBParm, AtAtIdentity, has been added to the 
Microsoft SQL Server (PBMSS70.DLL) interface. 

AtAtIdentity
--------------
Specifies what syntax the Microsoft SQL Server database interface 
uses to obtain the identity value of a new row in a database table.

When a DataWindow update request inserts a new row into a 
Microsoft SQL Server table that contains an IDENTITY column, the 
DataWindow engine calls PBMSS70 to obtain the identity value of 
the newly inserted row.  The AtAtIdentity DBParm allows you to 
define how this request is implemented.

Values are:

0   (Default) Use the syntax SELECT MAX(IDENTCOL) FROM <table name> 
to obtain the identity value of the newly inserted row

1   Use the syntax SELECT @@identity to obtain the identity value 
of the newly inserted row

By default, PBMSS70 issues SELECT MAX(IDENTCOL) FROM <table name>.  
This produces the correct result as long as two users are not updating 
the same table at the exact same time.  If your application does 
many concurrent updates to the same table, set AtAtIdentity = 1.    
 
When AtAtIdentity is set, PBMSS70 issues SELECT @@identity to obtain the 
IDENTITY column value of the newly inserted row.  If this request
is successful, you will have the correct identity value regardless 
of concurrent updates.  However, AtAtIdentity=1 may not work if the 
table containing the IDENTITY column has an insert trigger associated 
with it.  The insert trigger may perform another database activity 
(such as inserting a row in an activity log table) which causes 
the @@identity system variable to be reset to zero.

For this reason, you must decide on a case-by-case basis the best 
technique for obtaining newly inserted identity values.  
Since AtAtIdentity is a dynamic DBParm, it can be set and reset 
at any time during an application.

You can set the AtAtIdentity DBParm in the Transaction object of a 
PowerBuilder application script by typing the following: 
SQLCA.dbParm = "AtAtIdentity = '1'"
The AtAtIdentity DBParm cannot be set via the MSS Database Profile 
Setup dialog box.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿峰的编程博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值