Sequence # fetched back with insertion, 3 lines of code

Das Goravani das at
Tue Jan 30 21:34:03 EST 2018

Record Insertion, Serial Number Obtained, Value of that Retrieved, 3 lines of code

Do $cinst.$statementobject.$execdirect("INSERT INTO customers VALUES (nextval('seq_cust_id'),@[$cin…….name])  RETURNING (cust_id)") 
Do $cinst.$statementobject.$fetch(lvList,kFetchAll) Returns lReturnFlag
Calculate $cinst.cust_id as lvList.1.C1

Kelly put me into a table where $cinst. made sense in this case,  I figured out why it was not inserting,  and Bastiaan nailed the retrieval of the RETURNING cust_id and gave the idea for the use of “$statementobject” instead of an objects name

Notes: It was important that I note put single quotes on cust_id where it appears after the word “RETURNING”
Doing so returned that name, taking them off returned the desired serial integer
The single quotes on seq_cust_id are important or it doesn’t work
The above does get the Next Value from the sequence generator
And returns that value so that it can be put into the row and displayed onscreen
And used to connect child records for future joins and all the glory one could want
I can see how a REF to $cinst.$statementobject is in order to shorten up the lines, make ones typing less

More information about the omnisdev-en mailing list