Insert Row by enforcing ID
Hi Guys,
Can I insert a new row and enforcing my own ID not the default id increment?
&sql(INSERT INTO Sample.Person
(ID,Name,SSN)
VALUES ('205','Swift,Jonathan','111-22-3333'))
IF (SQLCODE = 0) {
Write "New Person inserted with ID: ", %ROWID,!
}
else
{WRITE !,"SQLCODE=",SQLCODE," ",%msg }
I tried this in samples and got the below error:
SQLCODE=-111 INSERT of Default Only RowID Field 'ID' in table 'Sample.Person' not allowed
thanks
Product version: Caché 2014.1
It depends on table definition. If you define your table with a PK that is not auto-increment (default) then you sure can pass your own ID.
You can assign your own ID: CREATE TABLE mytable (field1 INT PRIMARY KEY, field2 VARCHAR2)
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...