Closed fszilinski closed 4 years ago
OK, forget this question. The API itself AND the DML views are completely independent. It depends on the caller that have to pass the ID as value, so sequence and guid is possible, right?
Hi,
the best solution would be to use sys_guid as a default value in the table like so:
CREATE TABLE test (
id VARCHAR2(100 CHAR) DEFAULT ON NULL sys_guid() NOT NULL PRIMARY KEY,
value VARCHAR2(1000 CHAR)
);
BEGIN
om_tapigen.compile_api(p_table_name => 'TEST');
END;
/
BEGIN
test_api.create_row(p_id => NULL, p_value => 'test data');
test_api.create_row(p_id => sys_guid(), p_value => 'test data');
COMMIT;
END;
/
Then it does not matter if you provide the id in you business logic or not - it will work in both cases. Try it by yourself with the test script above.
As you already mentioned - it has nothing to do with the TAPI generator. The ability to provide a sequence name during the API generation is for old database releases which are not able to use a sequence as a column default and to create a table API without the need to create a trigger only for the sequence handling - this can be done then by the table API. If you have a newer DB release you don't need this anymore.
Hope this answers your question.
Kind regards Ottmar
Hi, is it possible to use SYS_GUID for primary key instead of sequence? APEX QuickDDL has this option but I like your generated API much more.