I have created selective unique index
CREATE UNIQUE INDEX fn_unique_idx
ON table1 (CASE WHEN is_deleted='N' THEN id ELSE null END,
CASE WHEN is_deleted='N' THEN name ELSE null END,
CASE WHEN is_deleted='N' THEN type ELSE null END);
So at any point of time I want only one entry with is_deleted 'N' for (id, name, type).
Insertion works fine ie it allows to enter mulitple is_deleted 'Y' and thows unique constriant exception when I try to insert with is_deleted = 'N' which is expected.
But when I try to update it is thowing oracle error:
ORA-00600: internal error code, arguments: [qctVCO : bfc], [1], [0], [1], [871], [1], [2], [875], [], [], [], []
SQL : UPDATE table1 set is_deleted = 'Y' where id = 1, name = 'foo' and type =bar';
I want to set this current entry as deleted and insert a new entry with updated data and is_deleted = 'N'. This is basically for maintaining the history.
Can someone help me fix this issue.
Thanks.
that type of error is an oracle internal error - aka a bug...
what patch version are you on? perhaps go the the current one just in case.
If I understand what you are trying to accomplish, you want to be able to have several rows with the same (id, name, type)
. For one of these rows is_deleted = 'N'
and for the rest of them is_deleted = 'Y'
.
Is that correct?
If so, let me offer some ideas:
is_deleted
field. Instead, have a version
field and whatever the latest version is, this is the row which is not deleted. The unique constraint/index then naturally covers (id, name, type, version)
. This can complicate querying though.archive_id
, archive_name
, archive_type
. The unique constraint still covers the original (id, name, type)
. The row is "deleted" by moving values to archive_*
fields and NULL-ifying the original fields. This should work because tuples that contain all NULLs are not included in the (unique) index.Also, let us know if there are any referential integrity constraints in play?
Agree with Branko on point #3 . You could also add START & END dates to this separate table for archival data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.