|
Oracle does not have autoincrement fields. By you can emulate it. For example, you have a table MyTable with field ID. That fields must be uniqe. For that you need create sequence: CREATE SEQUENCE MySchema.MySequence increment by 1 start with 1; and trigger for table MyTable, that will fill field ID from sequece: CREATE OR REPLACE TRIGGER MySchema.MyTrigger BEFORE INSERT ON MySchema.MyTable FOR EACH ROW BEGIN IF :new.ID is NULL THEN SELECT MySchema.MySequence.NEXTVAL INTO :new.ID FROM DUAL; END IF; END; / Now, what you must to do, what client software works correctly. You have two choices: 1) after post refresh record; 2) fill ID field on client, before posting record to server. In NCOCI8 you can achieve both with minimum gains. So, about choices ... For example, you have query on your form, named OCIQuery1. It contains SQL: 'select m.id, rowid from MyTable m'. Add persistent fields to OCIQuery1. 1) Select field 'ID' in property inspector, and set AutoGenerateValue = arAutoInc. Now after post OCIQuery1 will automatically refresh value of field 'ID'. 2) Select field 'ID' in property inspector, and set DefaultExpression = 'NEXTVAL(''MySchema.MySequence'')'. Now after insert field 'ID' will be filled by next value from sequence. In that case, it is possible to omit trigger creation.
|