1. Peter Klopfer
  2. PowerBuilder
  3. Monday, 16 December 2024 11:11 AM UTC

Hello,

I've a small data table with an identity field and an insert trigger saving the inserted values into a protocol table in another database.

In the datawindow, immediately after the insert the identity column doesn't contain the newly generated identity value of my table but the identity value of the protocol table. Another retrieve of the datawindow supplies the correct identity value.

My problem: I need the correct identity value immediately after the datawindow insert.

 

Here is what the trigger does:   insert into <protocol table> (fieldlist>) select <fieldlist> from ##inserted

 

Thanks in advance for any hint.

Regards, Peter

 

Who is viewing this page
Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 16 December 2024 13:37 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Peter;

  This is not uncommon when a trigger is involved. Try using a ReSelectRow to get the new key after the update. HTH 

Regards... Chris 

Comment
There are no comments made yet.
Peter Klopfer Accepted Answer Pending Moderation
  1. Monday, 16 December 2024 14:27 PM UTC
  2. PowerBuilder
  3. # 1

Hi Chris,

thank you for answering so promptly. 

ReSelectRow probably could be a pragmatic solution, but it throws the error "row changed between retrieve and reselect".

So I tried the following procedure:
- reload the identity value as with "select max(<idCol>) from <table>"
- setItem
- setItemStatus (..NotModified!)

Seems not to be the most elegant solution, but it works.

Regards... Peter

Comment
  1. Chris Pollach @Appeon
  2. Monday, 16 December 2024 20:24 PM UTC
Hi Peter;

If the ReSelectRow fails like that then that's normally the way you've mapped the update specifications.

Glad to hear that you found another alternative though! :-)

Regards ... Chris
  1. Helpful
  1. Peter Klopfer
  2. Monday, 16 December 2024 20:46 PM UTC
Chris,

thank you very much for valuable support - as ever

Peter
  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.