Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link SQL Related Articles: Retrieving Identity value from MSSQL 2003-11-24 -- Sebastian Streiger Newsgroups: softvelocity.public.clarion6
Access:Customer.TryInsert()
Customer{Prop:SQL} = 'SELECT @@IDENTITY'
If Access:Customer.TryNext() <> Level:Benign
!Something went wrong here
End
MESSAGE(Customer:SysId) !Now you should get what you wanted.
!This will return the value of the last identity inserted in the current session.
!No posible clash with other users
!I'm asumming that Customer:SysId is the first field in the Customers table.
!If it's not you should add dummy values to the select so that the identity fits the proper buffer
position
Just one warning. @@IDENTITY is a MSSQL variable, it won't work with another back-end.
Also it returns the last inserted identity of the current session, no matter wich tabl;e was the last
that was inserted into.
So you should be aware that a trigger for example can make the previous code errorneous.
Hpe this helps
--
Sebastián Streiger
IT Department
Red Megatone
Today is November 23, 2024, 2:15 am This article has been viewed 35212 times. Google search has resulted in 303 hits on this article since January 25, 2004.
|
|