Hello Oleska,
Much thanks for the help.
Your code snippet works well.
<selectKey resultClass="int" type="post" property="Id">
SELECT cast(IDENT_CURRENT('dbo.TableName') as int) AS ID
</selectKey>
However, I decided to use Pablo's code because there is no hard coded
table name.
<selectKey property="IdUsuario" resultClass="int">
SELECT cast(@@IDENTITY as int) as value
</selectKey>
>> Why there are so many empty lines in your message?
It was probably caused by my long email signature.
Your GMail service may have stripped it out.
Thanks again,
Gary Russo
-----Original Message-----
From: oleksa borodie [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 25, 2005 2:03 AM
To: [email protected]
Subject: Re: auto-key generation example
> If possible, please provide an example where an insert statement
returns the
> new key.
I could provide an example for MS SQL assigning new key value to the
object property.
You should add selectKey element to the insert element as follows:
<selectKey resultClass="int" type="post" property="ID">
SELECT cast(IDENT_CURRENT('dbo.TableName') as int) AS ID
</selectKey>
where "ID" - object property to hold key value and "TableName" - table
name with key identity.
When insert statement will be executed selectKey will assign new
identity value to the object property.
PS Why there are so many empty lines in your message? Or it's GMail bug?