You are not logged in.
Pages: 1
Good evening to all,
I need to assign the ID value directly in DB from an autoincremental value (ProstgreSQL). Database is shared with other applications.
There is a way for manage correctly the ORM Id so it can be assigned into DB and not as ( Select max id...) into TOrm class?
Thanks in advance!
Offline
There are several ways to do it in TRestStorageExternal.
The TRestStorageExternal.OnEngineAddComputeID method is defined for computing an ID before the INSERT.
You can put here some low-level SQL statement to get an ID, e.g. from a DB sequence.
If you want to let the DB create the ID, you may just set TRestStorageExternal.EngineAddForcedID to a non 0 value.
But note that this "fake" value will be returned by the ORM, not the actual ID value as inserted by the DB.
Offline
Hi Thanks,
I need this:
ID should not be passed into the sql of the db when making an insert, letting the db assign it autonomously in the rows. Then I get it when I run a query (retrieve, etc) for updates. In practice I ask if it is possible an option not to assign the ID in the add, without querying the db to retrieve the last ID before making insertion (for avoiding conflict on multiapp inserts). Pratically I'm looking for a way for don't assign ID in SQL insert.
Any help is welcome!
Thanks in advance
Offline
Hi Ab,
I have read your text, but I don't find EngineAddForcedID in documentation.
I will try to find some information in code.
Thanks a lot
Offline
The low-level documentation is written as part of the code, as comments.
Then they are extracted as
https://synopse.info/files/html/api-1.1 … C_45B30F67
Offline
Ah, Ok.
Thanks a lot!
Good job!
Offline
Pages: 1