When creating multi-level (chained) insert operations where the primary key of the parent MBO is set to autoincrement, use the "@@identity" parameter in the select statement to provide the chained insert value.
This method of creating a chained insert operation is useful if the primary key is set to autoincrement, you are making the relationship between two related Adaptive Server Enterprise/SQL Anywhere database mobile business objects, and you are creating them from the tool palette within the Mobile Application Diagram.
INSERT INTO sampledb.dba.customer
(
fname,
lname,
address,
city,
state,
zip,
phone,
company_name)
VALUES
('@OP["fname"=""]',
'@OP["lname"=""]',
'@OP["address"=""]',
'@OP["city"=""]',
'@OP["state"=""]',
'@OP["zip"=""]',
'@OP["phone"=""]',
'@OP["company_name"=""]'
)
SELECT * FROM sampledb.dba.customer WHERE id=@@IDENTITY
"id" is a primary key column of identity(or autoincrement) type. Notice that the extra select statement and 'id' are not part of the insert statement itself.