Changing a CLOB to a Varchar2
Posted on 2014-10-13
I have a situation where we have a CLOB when it should have been a varchar2(4000). We know that no data exceeds 4000 characters and want to convert the datatype.
I have created a new column of type Varchar2(4000 CHAR) successfully.
When I try and update the table to set the new column I get a constraint error and it is talking about deleting data
My code is
ALTER TABLE XXX ADD TITLE_VAR VARCHAR2(4000 CHAR);
UPDATEXXX SET TITLE_VAR = SUBSTR (TITLE, 1, 4000);
ALTER TABLE XXX DROP COLUMN TITLE;
ALTER TABLE XXX RENAME COLUMN TITLE_VAR TO TITLE;
The 1st line executes correctly, the second line however gives the following
SQL Error: ORA-02292: integrity constraint (AQD.FK_QACKLISTRES_QACKLISTITM) violated - child record found
02292. 00000 - "integrity constraint (%s.%s) violated - child record found"
*Cause: attempted to delete a parent key value that had a foreign
*Action: delete dependencies first then parent or disable constraint.
The foreign key being referred to is the primary key for this table being referenced by another table. The old and new columns being changed are not part of any relationship.
This error makes me think that Oracle is deleting the table and recreating - I can't think of any reason for this error.
It just doesn't make sense. The version of Oracle is 220.127.116.11 Enterprise with the code being run through SQL Developer.
I can't find any reference to this in any material anywhere. The solution I am using is widely quoted.
Does anyone have any ideas?