1. Jim Nesbitt
  2. PowerServer
  3. Friday, 26 May 2023 17:59 PM UTC

Hi

When PowerServer inserts a row into a SQL Server table with an identity column, does it use SCOPE_IDENTITY () to obtain the identity value for the inserted row?

I'm only asking this because the PowerBuilder documentation states that the default value for PowerBuider is @@identity. This may not work correctly in all cases, so I change it to use SCOPE_IDENTITY(), but this isn't possible using PowerServer. 

E.g.

If a row is inserted into table T1, and a trigger fires that inserts a row into T2.
@@IDENTITY returns the identity key for the row inserted in T2
SCOPE_IDENTITY() returns the identity key for the row inserted in T1

PowerBuilder identity Reference
https://docs.appeon.com/pb2022/connection_reference/Identity.html

Cheers

Jim

 

 

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 26 May 2023 19:13 PM UTC
  2. PowerServer
  3. # 1

Hi Jim;

  No

  What is does do though is see that it is an Identity column type and if so (and the Insert worked), it automatically issues a PowerScript ReSelectRow() command in the background after the PB Update() command. That ReSelectRow command then grabs the new key that SS assigned from the now newly inserted SS row.

HTH

Regards ... Chris

Comment
  1. Chris Pollach @Appeon
  2. Friday, 26 May 2023 20:45 PM UTC
Your most welcome Jim .. I am super glad that it now works!

Have you hugged a DataWindow today? ;-)
  1. Helpful
  1. Jim Nesbitt
  2. Monday, 29 May 2023 10:27 AM UTC
Hi Chris



I (metaphorically) hug them every day - they are the jewel in PowerBuilder's crown!



DW painter can be tedious, but I have a system to generate our DW text and column layout syntax, so I just have to edit the source and it's 99% done.



Cheers



Jim



  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 29 May 2023 15:05 PM UTC
Sounds great Jim! :-)
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.