How to configure generated Primary Key retrieval
- Last Updated: November 11, 2022
- 3 minute read
- Corticon
- Documentation
Corticon can retrieve the primary key (PK) when a record is inserted into a database, and then add it to working memory. This will allow database updates on that entity to occur, and also allows associated entities that are dependent on that primary key value to be stored as a foreign key value in the associated entity. Returning PKs to Corticon working memory should be avoided when not necessary as there is a performance impact.

true. The default is false, so if you do not want
the feature just do not set the property:When inserting records in child tables the Parent PK is needed so that you can set a Foreign Key (FK) relation to the parent. In the following example, the feature brings back the generated OrderID (PK) into Corticon working memory from the database, and then propagates the PK downward automatically to related (child) tables as FK through defined vocabulary associations.
One Query Name can hold multiple (sequenced) query insert statements, as they all read from Corticon working memory for variable substitution, so one WRITE Service Callout could do inserts of records into multiple tables.
When inserting large quantities of child records in a table with no dependent child tables,
you can get better performance when you create a separate WRITE Service Callout with Return
Generated Keys set to false or undefined.
In the following illustration, there are two table inserts. Procedures set Return Generated
Keys to true as it has dependent tables, while Rates sets Return Generated
Keys to false as there are no additional inserts in dependent tables.
In the Corticon Ruletest example's output on the right, the entity MEDICALPROCEDURE returns the primary key (ID), which propagates downward as a foreign key identifier to the RATES table. Then, on the RATES table, the primary key (ID) is not returned—and therefore not displayed in Corticon Tester—because the service callout Write procedure RATES to database has the property Return Generated Keys set to false (or undefined).