How to get last inserted RowID when %Save() function is used?
I need RowId of inserted record.
I have used below logic to get max row id,
but it will not give desired result when multiple people enter record in the table at the same time.
.png)
Comments
What purpose for the max RowId ?
Hi Vivek!
Instead of &sql ...
you can do:
write objExternalUser.%Id()So, If I am using objExternalUser.%Id() then which Id I ll get
1) Id of record inserted by my objExternalUser.%Save() function?
2) Id of latest inserted record?
Sorry Vivek. My code provides you the Id of objExternalUser you save (possible create) above. It's 1).
It's not the latest inserted record. I thought you need:
I need RowId of inserted record.
Out of curiosity: why do you need the latest record?
Thanks Evgency,
I got my answer, actually I need the Id of record inserted by my objExternalUser.%Save() function and that I got by your answer( objExternalUser.%Id() )
Great! Happy to hear that
When you create a class that the IDs are maintained by the system (standard class without modifying the storage, then there is a save mechanism to give a new ID to every new object that is being saved to the database.
Of course that when multiple users are saving new data simultaneously , a specific process ID after a %Save() might not be the last one in the table.