I would like to UPDATE a column value in a COLUMN TABLE with the NEXTVAL of a sequence.
So far, so good, this works:
hdbsql HDB=> CREATE COLUMN TABLE mytable (id NUMBER PRIMARY KEY, value NUMBER)
0 rows affected (8552 usec)
hdbsql HDB=> drop sequence s_myseq
0 rows affected (4230 usec)
hdbsql HDB=> CREATE SEQUENCE myseq
0 rows affected (3737 usec)
hdbsql HDB=> INSERT INTO mytable (id, value) VALUES (1, 1)
1 row affected (8635 usec)
hdbsql HDB=> UPDATE mytable SET value=myseq.nextval WHERE id=1
1 row affected (6875 usec)
If, however, there is a second table referencing "mytable" (and an actual entry referencing a "row" in mytable), the UPDATE with the sequence value will fail:
hdbsql HDB=> CREATE COLUMN TABLE othertable (id NUMBER NOT NULL, refid NUMBER NOT NULL, FOREIGN KEY(refid) REFERENCES mytable(id))
0 rows affected (9525 usec)
hdbsql HDB=> INSERT INTO othertable (id, refid) VALUES (1, 1)
1 row affected (5414 usec)
hdbsql HDB=> UPDATE mytable SET value=myseq.nextval WHERE id=1
* 2048: column store error: [1536] On Update/Delete action failed on referencing Table;from table DHOTEST:MYTABLEen to table DHOTEST:OTHERTABLEen, action=deindex, ref-action=restrict hit 1 rows in table DHOTEST:OTHERTABLEen SQLSTATE: HY000
If there is no entry in othertable referencing the updated value, the UPDATE will proceed.
What is the reasoning behind this, or is it a bug? Is there any way to perform this update without selecting the nextval in a separate statement first?
Thanks.