Ora-2270 Error while adding foreign key constraint on top a view
While adding a constraint, referencing a foreign key column from a view raises error. However, it works fine over a table.
Here's the sample script:
create table t_temp (
sample_id number,
text varchar2(40))
alter table t_temp add constraint temp_pk
primary key (sample_id);
create view tempvw as select sample_id,text from t_temp;
create table t_sample (
uniq_id number,
sample_id number,
sample_text varchar(40));
=========
ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp
FOREIGN KEY (sample_id) REFERENCES t_temp (sample_id);
This works fine.
=========
==============
The following raises ERROR....
ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp1
FOREIGN KEY (sample_id) REFERENCES tempvw (sample_id);
Error starting at line 1 in command:
ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp1
FOREIGN KEY (sample_id) REFERENCES tempvw (sample_id)
Error report:
SQL Error: ORA-02270: no matching unique or primary key for this column-list
02270. 00000 - "no matching unique or primary key for this column-list"
*Cause: A REFERENCES clause in a CREATE/ALTER TABLE statement
gives a column-list for which there is no matching unique or primary
key constraint in the referenced table.
*Action: Find the correct column names using the ALL_CONS_COLUMNS
catalog view
What exactly are you trying to accomplish by having a
referential integrity constraint on a view (which is
not allowed). PKs and FKs are allowed on views. DISABLE NOVALIDATE is the only allowed state for them. View constraints are used for query rewriting: http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/qradv.htm#sthref1457
Regards,
Dima
Similar Messages
-
Hi,
Problem:
When trying to add a Foreign Key via Edit Table | Foreign Key tab an error is thrown
Error:
"ORA-00942: table or view does not exit", Vendor code 942
SQL Developer Generated DDL:
ALTER TABLE "CNArticlesCODES"
DROP CONSTRAINT "CNArticlesCODES_FK1"
ALTER TABLE "CNArticlesCODES"
ADD CONSTRAINT "CNArticlesCODES_FK1" FOREIGN KEY
"ID"
) REFERENCES CNArticlesDATA
"ID"
) ENABLE
My work around:
table name next to REFERENCES command in double quotes
ALTER TABLE "CNArticlesCODES"
ADD CONSTRAINT "CNArticlesCODES_FK1" FOREIGN KEY
"UID"
) REFERENCES "CNArticlesCODES"
"UID"
) ENABLE
SQL Developer 1.0.0.15.57 on Windows XP SP2
Oracle Database 10g Enterprise Edition Release 10.2.0.10 (Eval Lic) on Windows 2003 Web Edition 32 bit
The 2 tables in this example where generated by MS DTS tool while importing data. This issue is not present when performing the above action on 2 tables generated using SQL Developer.
I'm no database expert and new to Oracle (R&D stage of SQL Server to Oracle migration). So can some body tell me/point me at docs that explains what's going on here with the table names.
ThanksHopefully someone from oracle will see this and log it as a bug. If that doesn't happen and you have a support license, you can open up a ticket with them directly.
As an aside.. if you are daring enough, the template for that is stored in one of the jars in an xml file. You can always edit it and add the quotes. Or..and you don't want to hear this.. you may want to rename everything to uppercase. It would hurt now, but could end up saving you time down the road. (adding quotes to every query is a pain)
Eric -
Error while enabling forien key constraint
HI forum,
I am facing a problem while enabling constraint..pls see the statement below.
SQL> alter table EVENT enable validate constraint EVENT_4FK;
alter table EVENT enable validate constraint EVENT_4FK
ERROR at line 1:
ORA-02298: cannot validate (APPO.EVENT_4FK) - parent keys not
found
EVENT_4FK FK is refering another table and that primary key is existing and it is in enabled ...
Pls help me to solve this issue..
Thanksalter table event enable validate constraint event_4fk exceptions into exceptions;check the offending row(s) in the exceptions table. (See the documentation for how to create an exceptions table if not present).
-
Error while adding a attribute to the the Custom view through a wizard
Hi ,
I have created a new custom view with value node through wizard succesfully.
Now I want to add a new attribute to that node.I am trying to do that by a wizard.
But i am getting the follwing error " Error during analysis of Source Code" although i have
commented or removed my all custom code from that view.
I tried adding the new aattributes in the metthods "IF_BSP_MODEL~INIT " and
"GET_TABLE_LINE_SAMPLE " manually but that also does not worked.
Plz help me with this asap.
Regards,
SharadHi Sharad,
I hope all your classes are active. In case you want to add a new attribute there are two steps.
1.Right click on context node and create attribute, it opens a wizard and continue. This will add the field in the context node and generate the getter-setter methods.
2. In the above two method whcih you mentioned add the new field in the structure of value node. And then create your own getter-setter methods. and activate it. After this you will be able to see the attribute added in the context node.
By using any of the two approaches you will be able to see teh new field in the configuration.
Hope this helps.
Regards,
Ruby. -
Using FOreign key constraints on tables in database.
I am student and novice in the field of ORACLE and PL/SQL and Database Creation. I had created a database consisting tables and got problem while applying foreign key constraints.
CUST_MSTR
CREATE TABLE "DBA_BANKSYS"."CUST_MSTR"("CUST_NO" VARCHAR2(10),
"FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25), "LNAME" VARCHAR2(25),
"DOB_INC" DATE NOT NULL, "OCCUP" VARCHAR2(25), "PHOTOGRAPH" VARCHAR2(25),
"SIGNATURE" VARCHAR2(25), "PANCOPY" VARCHAR2(1), "FORM60" VARCHAR2(1));
(CUST_NO is PRIMARY KEY, )
-- EMP_MSTR
CREATE TABLE "DBA_BANKSYS"."EMP_MSTR"("EMP_NO" VARCHAR2(10),
"BRANCH_NO" VARCHAR2(10), "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25),
"LNAME" VARCHAR2(25), "DEPT" VARCHAR2(30), "DESIG" VARCHAR2(30));
(EMP_NO is primary key )
--NOMINEE_MSTR
CREATE TABLE "DBA_BANKSYS"."NOMINEE_MSTR"("NOMINEE_NO" VARCHAR2(10),
"ACCT_FD_NO" VARCHAR2(10), "NAME" VARCHAR2(75), "DOB" DATE,
RELATIONSHIP" VARCHAR2(25));
(NOMINEE_NO is primary key )
--ADDR_DTLS
CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
"CODE_NO" VARCHAR2(10), "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
"ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
"PINCODE" VARCHAR2(6));
( ADDR_NO is primary key )
Problem: I want to apply foreign key constraints on ADDR_DTLS table so that Before inserting value in ADDR_DTLS table it must check, VALUE in ADDR_DTLS.CODE_NO must be PRESENT either in attribute value CUST_MSTR.CODE_NO or EMP_MSTR.CODE_NO or NOMINEE_MSTR.CODE_NO table .
I applied the foreign key constraints using this syntax
CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
"CODE_NO" VARCHAR2(10), "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
"ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
"PINCODE" VARCHAR2(6),
constraints fk_add foreign key CODE_NO references CUST_MSTR. CODE_NO,
constraints fk_add1 foreign key CODE_NO references EMP_MSTR. CODE_NO,
constraints fk_add2 foreign key CODE_NO references NOMINEE_MSTR.CODE_NO);
(foreign key)
ADDR_DTLS.CODE_NO ->CUST_MSTR.CUST_NO
ADDR_DTLS.CODE_NO ->NOMINEE_MSTR.NOMINEE_NO
ADDR_DTLS.CODE_NO ->BRANCH_MSTR.BRANCH_NO
ADDR_DTLS.CODE_NO ->EMP_MSTR.EMP_NO
When I applied foreign key constraints this way, its gives a error called foreign key constraints violation. (I understand that, its searches the attribute value of ADDR_DTLS.CODE_NO in all the three tables must be present then the value will be inserted. But I want, if the value is in any of the three table then its should insert the value or its gives an error.)
Please help me out, though i put the question and i want too know how to apply the forign key in this way. and is there any other option if foreign key implementation is not pssible.If you are on 11g you can use ON DELETE SET NULL:
CREATE TABLE addr_dtls
( addr_no NUMBER(6) CONSTRAINT addr_pk PRIMARY KEY
, addr_cust_no CONSTRAINT addr_cust_fk REFERENCES cust_mstr ON DELETE SET NULL
, addr_emp_no CONSTRAINT addr_emp_fk REFERENCES emp_mstr ON DELETE SET NULL
, addr_nominee_no CONSTRAINT addr_nominee_fk REFERENCES nominee_mstr ON DELETE SET NULL
, addr_type VARCHAR2(1)
, addr1 VARCHAR2(50)
, addr2 VARCHAR2(50)
, city VARCHAR2(25)
, state VARCHAR2(25)
, pincode VARCHAR2(6) );In earlier versions you'll need to code some application logic to do something similar when a parent row is deleted, as otherwise the only options are to delete the dependent rows or raise an error.
btw table names can be up to 30 characters and don't need to end with MSTR or DTLS, so for example CUSTOMERS and ADDRESSES might be more readable than CUST_MSTR and ADDR_DTLS. Also if the Customer/Employee/Nominee PKs are generated from a sequence they should be numeric.
Edited by: William Robertson on Aug 15, 2010 6:47 PM -
Error while adding Image: ORA-00001: unique constraint
Dear all,
I have an error while adding images to MDM I can´t explain. I want to add 7231 images. About 6983 run fine. The rest throws this error.
Error: Service 'SRM_MDM_CATALOG', Schema 'SRMMDMCATALOG2_m000', ERROR CODE=1 ||| ORA-00001: unique constraint (SRMMDMCATALOG2_M000.IDATA_6_DATAID) violated
Last CMD: INSERT INTO A2i_Data_6 (PermanentId, DataId, DataGroupId, Description_L3, CodeName, Name_L3) VALUES (:1, :2, :3, :4, :5, :6)
Name=PermanentId; Type=9; Value=1641157; ArraySize=0; NullInd=0;
Name=DataId; Type=5; Value=426458; ArraySize=0; NullInd=0;
Name=DataGroupId; Type=4; Value=9; ArraySize=0; NullInd=0;
Name=Description_L3; Type=2; Value=; ArraySize=0; NullInd=0;
Name=CodeName; Type=2; Value=207603_Img8078_gif; ArraySize=0; NullInd=0;
Name=Name_L3; Type=2; Value=207603_Img8078.gif; ArraySize=0; NullInd=0;
Error: Service 'SRM_MDM_CATALOG', Schema 'SRMMDMCATALOG2_m000', ERROR CODE=1 ||| ORA-00001: unique constraint (SRMMDMCATALOG2_M000.IDATA_6_DATAID) violated
Last CMD: INSERT INTO A2i_Data_6 (PermanentId, DataId, DataGroupId, Description_L3, CodeName, Name_L3) VALUES (:1, :2, :3, :4, :5, :6)
Name=PermanentId; Type=9; Value=1641157; ArraySize=0; NullInd=0;
Name=DataId; Type=5; Value=426458; ArraySize=0; NullInd=0;
Name=DataGroupId; Type=4; Value=9; ArraySize=0; NullInd=0;
Name=Description_L3; Type=2; Value=; ArraySize=0; NullInd=0;
Name=CodeName; Type=2; Value=207603_Img8085_gif; ArraySize=0; NullInd=0;
Name=Name_L3; Type=2; Value=207603_Img8085.gif; ArraySize=0; NullInd=0;
I checked all data. There is no such dataset in the database. Can anybody give me a hint how to avoid this error.
One thing I wonder: The PermanentId is allways the same but I can´t do anything here.
BR
Roman
Edited by: Roman Becker on Jan 13, 2009 12:59 AMHi Ritam,
For such issues, can you please create a new thread or directly email the author rather than dragging back up a very old thread, it is unlikely that the resolution would be the same as the database/application/etc releases would most probably be very different.
For now I will close this thread as unanswered.
SAP SRM Moderators. -
Hi,
I have a table (num of rows 60,00,000). I am adding a foreign key constraint
through alter table option but it is taking very long time to complete...
Any other methods to enhance the performance......Please read about [url http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96524/c22integ.htm#6719]Constraint States in the manual.
-
I am getting the following error while adding record into the table CM_RECIPE_ITEM :
<h4> Error </h4>
ORA-20505: Error in DML: p_rowid=626, p_alt_rowid=CRI_ID, p_rowid2=, p_alt_rowid2=. ORA-01410: invalid ROWID ORA-06512: at "COSTMAN.CM_RECIPE_ITEM_T3_AFTER", line 11 ORA-04088: error during execution of trigger 'COSTMAN.CM_RECIPE_ITEM_T3_AFTER'
Error Unable to process row of table CM_RECIPE_ITEM.
Kindly suggest if the problem is because of the Global temporary table or the triggers given below. Also suggest the solution.
Thanking You,
Yogesh
<h4> CM_RECIPE_ITEM Table </h4>
CRI_ID------CRI_CR_ID--------CRI_BOM_CODE--------CRI_CIFG_CODE---------CRI_CIRM_CODE--------CRI_SEQ--------CRI_QTY--------CRI_RM_COST
625----------464-----------------PRODUCT3001----------FG003----------------------10---------------------------1-------------------60-----------------10
626----------464-----------------PRODUCT3001----------FG003----------------------12---------------------------2-------------------40------------------10
<h4>Global temporary table</h4>
DROP TABLE COSTMAN.INTERIM CASCADE CONSTRAINTS;
CREATE GLOBAL TEMPORARY TABLE COSTMAN.INTERIM
ROW_ID ROWID
ON COMMIT PRESERVE ROWS
NOCACHE;
CREATE OR REPLACE TRIGGER COSTMAN."CM_RECIPE_ITEM_T3"
BEFORE INSERT OR UPDATE ON "CM_RECIPE_ITEM" FOR EACH ROW
BEGIN
INSERT INTO interim VALUES (:new.rowid);
END;
<h4>Trigger to update data on CM_RECIPE table </h4>
CREATE OR REPLACE TRIGGER COSTMAN."CM_RECIPE_ITEM_T3_AFTER"
AFTER INSERT OR UPDATE ON "CM_RECIPE_ITEM"
BEGIN
FOR ds IN (SELECT row_id FROM interim) LOOP
UPDATE CM_RECIPE
SET CR_RMC = (
SELECT SUM(CRI_QTY * CRI_RM_COST)/SUM(CR_QUANTITY)
FROM CM_RECIPE_ITEM
WHERE CRI_BOM_CODE = CR_BOM_CODE
AND rowid = ds.row_id
UPDATE CM_RECIPE
SET CR_TOTAL_COST = (
SELECT CIFG_PACKING + CIFG_OVERHEAD +CIFG_OTHERS
FROM CM_ITEM_FG
WHERE CIFG_CODE = CR_CIFG_CODE
AND rowid = ds.row_id
) + CR_RMC;
UPDATE CM_RECIPE
SET CR_GROSS_MARGIN =
(SELECT CIFG_DP_RATE
FROM CM_ITEM_FG
WHERE CIFG_CODE = CR_CIFG_CODE
AND rowid = ds.row_id) - CR_TOTAL_COST) / CR_TOTAL_COST;
END LOOP;
END;
/The scripts of the tables CM_ITEM_FG, CM_RECIPE, CM_RECIPE_ITEM are as follows :
<h4>CM_ITEM_FG</h4>
ALTER TABLE COSTMAN.CM_ITEM_FG
DROP PRIMARY KEY CASCADE;
DROP TABLE COSTMAN.CM_ITEM_FG CASCADE CONSTRAINTS;
CREATE TABLE COSTMAN.CM_ITEM_FG
CIFG_CODE VARCHAR2(13 BYTE) NOT NULL,
CIFG_CCG_ID NUMBER NOT NULL,
CIFG_NAME VARCHAR2(50 BYTE) NOT NULL,
CIFG_PACKING NUMBER NOT NULL,
CIFG_OVERHEAD NUMBER NOT NULL,
CIFG_OTHERS NUMBER NOT NULL,
CIFG_DP_RATE NUMBER NOT NULL,
CIFG_CR_BY VARCHAR2(32 BYTE),
CIFG_CR_ON DATE,
CIFG_UPD_BY VARCHAR2(32 BYTE),
CIFG_UPD_ON DATE
TABLESPACE COST_MANAGER
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE UNIQUE INDEX COSTMAN.CM_ITEM_FG_PK_001 ON COSTMAN.CM_ITEM_FG
(CIFG_CODE, CIFG_CCG_ID)
LOGGING
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
CREATE UNIQUE INDEX COSTMAN.CM_ITEM_FG_UK_001 ON COSTMAN.CM_ITEM_FG
(CIFG_CODE)
LOGGING
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
CREATE OR REPLACE TRIGGER COSTMAN."CM_ITEM_FG_T1"
BEFORE UPDATE ON "CM_ITEM_FG"
FOR EACH ROW
BEGIN
BEGIN
UPDATE CM_RECIPE
SET CR_TOTAL_COST = (CR_RMC + :NEW.CIFG_PACKING + :NEW.CIFG_OVERHEAD + :NEW.CIFG_OTHERS);
END;
BEGIN
UPDATE CM_RECIPE
SET CR_GROSS_MARGIN = (:NEW.CIFG_DP_RATE - CR_TOTAL_COST) / CR_TOTAL_COST;
END;
END;
ALTER TABLE COSTMAN.CM_ITEM_FG ADD (
CONSTRAINT CM_ITEM_FG_PK_001
PRIMARY KEY
(CIFG_CODE, CIFG_CCG_ID)
USING INDEX
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
CONSTRAINT CM_ITEM_FG_UK_001
UNIQUE (CIFG_CODE)
USING INDEX
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
ALTER TABLE COSTMAN.CM_ITEM_FG ADD (
CONSTRAINT CM_ITEM_FG_FK_001
FOREIGN KEY (CIFG_CCG_ID)
REFERENCES COSTMAN.CM_COST_GROUP (CCG_ID));
<h4>CM_RECIPE</H4>
ALTER TABLE COSTMAN.CM_RECIPE
DROP PRIMARY KEY CASCADE;
DROP TABLE COSTMAN.CM_RECIPE CASCADE CONSTRAINTS;
CREATE TABLE COSTMAN.CM_RECIPE
CR_ID NUMBER NOT NULL,
CR_CCG_ID NUMBER,
CR_EFF_FROM DATE,
CR_CIFG_CODE VARCHAR2(10 BYTE) NOT NULL,
CR_BOM_CODE VARCHAR2(50 BYTE),
CR_QUANTITY NUMBER,
CR_RMC NUMBER,
CR_TOTAL_COST NUMBER,
CR_GROSS_MARGIN NUMBER,
CR_CR_BY VARCHAR2(32 BYTE),
CR_CR_ON DATE,
CR_UPD_BY VARCHAR2(32 BYTE),
CR_UPD_ON DATE
TABLESPACE COST_MANAGER
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE UNIQUE INDEX COSTMAN.CM_RECIPE_PK_001 ON COSTMAN.CM_RECIPE
(CR_CCG_ID, CR_ID, CR_CIFG_CODE)
LOGGING
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
CREATE UNIQUE INDEX COSTMAN.CM_RECIPE_UK_001 ON COSTMAN.CM_RECIPE
(CR_ID)
LOGGING
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
CREATE UNIQUE INDEX COSTMAN.CM_RECIPE_UK_002 ON COSTMAN.CM_RECIPE
(CR_BOM_CODE)
LOGGING
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
CREATE OR REPLACE TRIGGER COSTMAN."CM_RECIPE_T1"
BEFORE INSERT ON "CM_RECIPE"
FOR EACH ROW
DECLARE
L_ID NUMBER;
BEGIN
IF INSERTING THEN
IF :NEW.CR_ID IS NULL THEN
--SELECT CM_RECIPE_SEQ.NEXTVAL INTO L_ID FROM DUAL;
:NEW.CR_ID := CM_RECIPE_SEQ.NEXTVAL; --L_ID;
END IF;
:NEW.CR_CR_ON := SYSDATE;
:NEW.CR_CR_BY := nvl(v('APP_USER'),USER);
END IF;
IF UPDATING THEN
:NEW.CR_UPD_ON := SYSDATE;
:NEW.CR_UPD_BY := nvl(v('APP_USER'),USER);
END IF;
END;
ALTER TABLE COSTMAN.CM_RECIPE ADD (
CHECK ("CR_EFF_FROM" IS NOT NULL) DISABLE,
CHECK ("CR_CCG_ID" IS NOT NULL) DISABLE,
CHECK ("CR_QUANTITY" IS NOT NULL) DISABLE,
CHECK ("CR_QUANTITY" IS NOT NULL) DISABLE,
CHECK ("CR_QUANTITY" IS NOT NULL) DISABLE,
CHECK ("CR_QUANTITY" IS NOT NULL) DISABLE,
CHECK ("CR_QUANTITY" IS NOT NULL) DISABLE,
CHECK ("CR_QUANTITY" IS NOT NULL) DISABLE,
CONSTRAINT CM_RECIPE_PK_001
PRIMARY KEY
(CR_ID)
USING INDEX
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
CONSTRAINT CM_RECIPE_UK_002
UNIQUE (CR_BOM_CODE)
USING INDEX
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
<h4>CM_RECIPE_ITEM</H4>
ALTER TABLE COSTMAN.CM_RECIPE_ITEM
DROP PRIMARY KEY CASCADE;
DROP TABLE COSTMAN.CM_RECIPE_ITEM CASCADE CONSTRAINTS;
CREATE TABLE COSTMAN.CM_RECIPE_ITEM
CRI_ID NUMBER NOT NULL,
CRI_CR_ID NUMBER NOT NULL,
CRI_BOM_CODE VARCHAR2(50 BYTE) NOT NULL,
CRI_CIFG_CODE VARCHAR2(10 BYTE) NOT NULL,
CRI_CIRM_CODE VARCHAR2(10 BYTE) NOT NULL,
CRI_SEQ NUMBER,
CRI_QTY NUMBER,
CRI_RM_COST NUMBER,
CRI_CR_BY VARCHAR2(32 BYTE),
CRI_CR_ON DATE,
CRI_UPD_BY VARCHAR2(32 BYTE),
CRI_UPD_ON DATE
TABLESPACE COST_MANAGER
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE UNIQUE INDEX COSTMAN.CM_RECIPE_ITEM_PK_001 ON COSTMAN.CM_RECIPE_ITEM
(CRI_ID)
LOGGING
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
CREATE OR REPLACE TRIGGER COSTMAN."CM_RECIPE_ITEM_T2"
BEFORE INSERT OR UPDATE ON "CM_RECIPE_ITEM"
FOR EACH ROW
BEGIN
IF :NEW.CRI_CR_ID IS NULL THEN
SELECT CR_ID INTO :NEW.CRI_CR_ID
FROM CM_RECIPE
WHERE CR_BOM_CODE = :NEW.CRI_BOM_CODE;
END IF;
END;
CREATE OR REPLACE TRIGGER COSTMAN."CM_RECIPE_ITEM_T1" BEFORE
INSERT OR UPDATE ON "CM_RECIPE_ITEM" FOR EACH ROW
DECLARE
L_ID NUMBER;
SEQ NUMBER;
BEGIN
IF INSERTING THEN
IF :NEW.CRI_ID IS NULL THEN
SELECT CM_RECIPE_ITEM_SEQ.NEXTVAL
INTO :NEW.CRI_ID
FROM dual;
END IF;
:NEW.CRI_CR_ON := SYSDATE;
:NEW.CRI_CR_BY := NVL(v('APP_USER'),USER);
SELECT (NVL(MAX(CRI_SEQ),0)+1)
INTO SEQ
FROM CM_RECIPE_ITEM
WHERE CRI_BOM_CODE = :NEW.CRI_BOM_CODE;
:NEW.CRI_SEQ := SEQ;
END IF;
IF UPDATING THEN
:NEW.CRI_UPD_ON := SYSDATE;
:NEW.CRI_UPD_BY := NVL(v('APP_USER'),USER);
END IF;
END;
ALTER TABLE COSTMAN.CM_RECIPE_ITEM ADD (
CHECK ("CRI_RM_COST" IS NOT NULL) DISABLE,
CHECK ("CRI_QTY" IS NOT NULL) DISABLE,
CHECK ("CRI_SEQ" IS NOT NULL) DISABLE,
CONSTRAINT CM_RECIPE_ITEM_PK_001
PRIMARY KEY
(CRI_ID)
USING INDEX
TABLESPACE COST_MANAGER
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
ALTER TABLE COSTMAN.CM_RECIPE_ITEM ADD (
CONSTRAINT CM_RECIPE_FK_002
FOREIGN KEY (CRI_CIRM_CODE)
REFERENCES COSTMAN.CM_ITEM_RM (CIRM_CODE),
CONSTRAINT CM_RECIPE_ITEM_FK_001
FOREIGN KEY (CRI_CR_ID)
REFERENCES COSTMAN.CM_RECIPE (CR_ID));
Yogesh -
I am getting the following error while adding record into the table CM_RECIPE_ITEM :
Error
ORA-20505: Error in DML: p_rowid=626, p_alt_rowid=CRI_ID, p_rowid2=, p_alt_rowid2=. ORA-01410: invalid ROWID ORA-06512: at "COSTMAN.CM_RECIPE_ITEM_T3_AFTER", line 11 ORA-04088: error during execution of trigger 'COSTMAN.CM_RECIPE_ITEM_T3_AFTER'
Error Unable to process row of table CM_RECIPE_ITEM.
Kindly suggest if the problem is because of the Global temporary table or the triggers given below. Also suggest the solution.
Thanking You,
Yogesh
CM_RECIPE_ITEM Table
CRI_ID------CRI_CR_ID--------CRI_BOM_CODE--------CRI_CIFG_CODE---------CRI_CIRM_CODE--------CRI_SEQ--------CRI_QTY--------CRI_RM_COST
625----------464-----------------PRODUCT3001----------FG003----------------------10---------------------------1-------------------60-----------------10
626----------464-----------------PRODUCT3001----------FG003----------------------12---------------------------2-------------------40------------------10
Global temporary table
DROP TABLE COSTMAN.INTERIM CASCADE CONSTRAINTS;
CREATE GLOBAL TEMPORARY TABLE COSTMAN.INTERIM
ROW_ID ROWID
ON COMMIT PRESERVE ROWS
NOCACHE;
CREATE OR REPLACE TRIGGER COSTMAN."CM_RECIPE_ITEM_T3"
BEFORE INSERT OR UPDATE ON "CM_RECIPE_ITEM" FOR EACH ROW
BEGIN
INSERT INTO interim VALUES (:new.rowid);
END;
Trigger to update data on CM_RECIPE table
CREATE OR REPLACE TRIGGER COSTMAN."CM_RECIPE_ITEM_T3_AFTER"
AFTER INSERT OR UPDATE ON "CM_RECIPE_ITEM"
BEGIN
FOR ds IN (SELECT row_id FROM interim) LOOP
UPDATE CM_RECIPE
SET CR_RMC = (
SELECT SUM(CRI_QTY * CRI_RM_COST)/SUM(CR_QUANTITY)
FROM CM_RECIPE_ITEM
WHERE CRI_BOM_CODE = CR_BOM_CODE
AND rowid = ds.row_id
UPDATE CM_RECIPE
SET CR_TOTAL_COST = (
SELECT CIFG_PACKING + CIFG_OVERHEAD +CIFG_OTHERS
FROM CM_ITEM_FG
WHERE CIFG_CODE = CR_CIFG_CODE
AND rowid = ds.row_id
) + CR_RMC;
UPDATE CM_RECIPE
SET CR_GROSS_MARGIN =
(SELECT CIFG_DP_RATE
FROM CM_ITEM_FG
WHERE CIFG_CODE = CR_CIFG_CODE
AND rowid = ds.row_id) - CR_TOTAL_COST) / CR_TOTAL_COST;
END LOOP;
END;
/yogeshyl wrote:
Error
ORA-20505: Error in DML: p_rowid=626, p_alt_rowid=CRI_ID, p_rowid2=, p_alt_rowid2=. ORA-01410: invalid ROWID ORA-06512: at "COSTMAN.CM_RECIPE_ITEM_T3_AFTER", line 11 ORA-04088: error during execution of trigger 'COSTMAN.CM_RECIPE_ITEM_T3_AFTER'
Error Unable to process row of table CM_RECIPE_ITEM.
Kindly suggest if the problem is because of the Global temporary table or the triggers given below. Also suggest the solution.The error message points to the trigger... -
Import table data in right order to avoid violating foreign key constraints
Gentlemen
I am trying to import table data into an existing 10g schema using datapump import in table mode.
However, in order to avoid violating foreign key constraints, the tables must be loaded in a specified order. I tried specifying the order in the TABLES parameter:
TABLES=table1,table2,table3 etc.
However, datapump seems to chose its own order leading to errors like the following:
ORA-31693: Table data object "SCHEMAX"."TABLE3" failed to load/unload and is being skipped due to error:
ORA-02291: integrity constraint (SCHEMAX.TABLE3_TABLE1#FK) violated - parent key not found
I want to try to avoid having to disable all foreign keys because there are hundreds of them.
Any advice?
Yours
Claus Jacobsen, DenmarkThanks Anantha.
Since I am only loadding data (the constraints are already defined in the target database), I am not sure whether this approach would work. Meanwhile I have solved the problem of moving data from one system to another using another, tedious and far from elegant approach that I would prefer to not eloborate on:-)
However, I have also discovered another probable reason why the foreign key constraints were violated, other than wrong order of table data loading. It turns out almost every single table in the schema contains a trigger supposed to generate a unique row ID from a sequence on insert such as:
CREATE OR REPLACE TRIGGER "SCHEMAX"."TABLEX#B_I_R"
BEFORE INSERT
ON TABLEX
FOR EACH ROW
DECLARE
BEGIN
SELECT tablex_seq.nextval INTO :NEW.ID FROM dual;
END;
If the import mechanism fires this trigger, and the sequences in the source and the target systems are not synchronized, then I guess that referred records a more than likely to end up with wrong ID's compared to the row ID's in the referring rows?
Spooky. Anybody can confirm this theory?
Yours
Claus
Message was edited by:
user586249 -
Wrong order foreign key constraints
Hi,
i have problems with non-deferred foreing key constraints:
I have a table "PERSON" and a table "ADRESSE" which has a foreign key
to "PERSON". Both tables have primary keys with two columns.
In the mappings I use application identity. The mappings are generated by
xdoclet.
We cannot use deferred constraint because we have to support following
databases: Oracle, Firebird, MS SQL, DB2.
I tested the mappings with Oracle and Firebird and got this exception
(with SQL Trace):
5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (1 errors)>
[15 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
04941 183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751,
(String) Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null,
(String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]
5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
[0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12764,
(int) 1, (int) 0, (null) null, (String) Sylt, (int) 12759, (String) 25980,
(int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
[reused=1]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
[0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
null, (int) 12759, (String) 9999452800, (null) null, (int) 1, (String)
Horstmann, (String) Manfred, (Timestamp) 1959-03-10 00:00:00.381, (String)
Flensburg, (int) 1] [reused=0]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
[0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
04941 183742, (int) 12763, (int) 1, (int) 1, (String) 0171 2846751,
(String) Oldenburg, (int) 12759, (String) 26129, (int) 1, (null) null,
(String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=2]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12762,
(int) 1, (int) 0, (null) null, (String) Sylt, (int) 12760, (String) 25980,
(int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
[reused=3]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
null, (int) 12760, (String) 9999452801, (null) null, (int) 1, (String)
Horstmann, (String) Christine, (Timestamp) 1972-03-10 00:00:00.381,
(String) Erfurt, (int) 1] [reused=1]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
(ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
[params=(int) 0, (null) null, (double) 0.0, (null) null, (int) 12410,
(int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12760,
(int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
null] [reused=0]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
(ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
[params=(int) 0, (null) null, (double) 0.0, (int) 12362, (int) 12378,
(int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12759,
(int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
null] [reused=1]
5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
errors)> [16 ms] rollback
5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
errors)> return
5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
errors)> [0 ms] close
com.solarmetric.jdbc.ReportingSQLException: ORA-02291: integrity
constraint (VAMP.ADRESSE_PS) violated - parent key not found
{prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART, EMAIL, FAXNR,
ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ, POSTADRESSE,
POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?) [params=(int) 1, (String) [email protected], (String) 04941
183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751, (String)
Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null, (String)
Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]} [code=2291,
state=23000]
at
com.solarmetric.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:124)
at
com.solarmetric.jdbc.LoggingConnectionDecorator.access$600(LoggingConnectionDecorator.java:19)
at
com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:728)
at
com.solarmetric.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:362)
How can I force it to insert in the table "NATPERSON" first and then in
the table "ADRESSE"?
I use following JDBC-drivers:
Firebird: 1.5.5
Oracle: 9.2.0.1.0
My property file:
<!-- standard properties for all dbms -->
<prop key="kodo.LicenseKey">LICENSE KEY REMOVED</prop>
<prop key="kodo.ConnectionFactoryProperties">MaxCachedStatements=150,
MaxActive=50, MaxIdle=50</prop>
<prop key="kodo.FetchBatchSize">200</prop>
<prop key="kodo.DataCache">true(CacheSize=5000)</prop>
<prop key="kodo.RemoteCommitProvider">sjvm</prop>
<prop key="kodo.jdbc.MappingFactory">metadata</prop>
<prop key="kodo.jdbc.ForeignKeyConstraints">true</prop>
<prop key="kodo.jdbc.SchemaFactory">native</prop>
<prop
key="javax.jdo.PersistenceManagerFactoryClass">kodo.jdbc.runtime.JDBCPersistenceManagerFactory</prop>
<prop key="javax.jdo.option.Optimistic">true</prop>
<!-- oracle connection properties -->
<prop key="kodo.jdbc.DBDictionary">oracle</prop>
<prop
key="javax.jdo.option.ConnectionDriverName">oracle.jdbc.driver.OracleDriver</prop>
<prop key="javax.jdo.option.ConnectionURL">..</prop>
<prop key="javax.jdo.option.ConnectionUserName">..</prop>
<prop key="javax.jdo.option.ConnectionPassword">..</prop>
<prop key="kodo.jdbc.SequenceFactory">native</prop>
<prop key="kodo.jdbc.Schemas">..</prop>
<!-- firebird connection properties
<prop key="kodo.jdbc.DBDictionary">kodo.jdbc.sql.FirebirdDictionary</prop>
<prop
key="javax.jdo.option.ConnectionDriverName">org.firebirdsql.jdbc.FBDriver</prop>
<prop key="javax.jdo.option.ConnectionURL">..</prop>
<prop key="javax.jdo.option.ConnectionUserName">..</prop>
<prop key="javax.jdo.option.ConnectionPassword">..</prop>
<prop key="kodo.jdbc.SequenceFactory">native(TableName=SYSDUAL,
Format="SELECT GEN_ID({0},1) FROM {1}")</prop>
-->
My database schema looks like this:
TABLE PERSON
FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
FIELD ID (AUTOINC COMMENT (""))
FIELD TYP (SMALLINT REQUIRED COMMENT (""))
FIELD KUNDENNR (CHAR(15) COMMENT ("Kundennummer"))
PRIMARY KEY
FIELD MANDANTID
FIELD ID
FOREIGN KEY MD
TABLE MANDANT
FIELD MANDANTID
INDEX KDNR
FIELD MANDANTID
FIELD KUNDENNR
UNIQUE
TABLE ADRESSE
FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
FIELD ID (AUTOINC COMMENT (""))
FIELD PERSONID (LONGINT REQUIRED COMMENT (""))
PRIMARY KEY
FIELD MANDANTID
FIELD ID
FOREIGN KEY PS
TABLE PERSON
FIELD MANDANTID
FIELD PERSONID
My metadata looks like this:
<class name="PersonDO"
identity-type="application"
objectid-class="com.elaxy.vamp.dom.person.PersonDOId"
persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
<extension vendor-name="kodo"
key="jdbc-class-ind"
value="metadata-value">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-ind/column"
value="TYP">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-ind-value"
value="-1">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-map"
value="base">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-map/table"
value="PERSON">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
value="ID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
value="MANDANTID">
</extension>
<field name="kundenNr"
persistence-modifier="persistent">
</field>
<field name="adressen"
persistence-modifier="persistent">
<collection
element-type="com.elaxy.vamp.dom.person.AdresseDO">
</collection>
<extension vendor-name="kodo"
key="jdbc-field-map"
value="one-many">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-map/ref-column.MANDANTID"
value="MANDANTID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-map/ref-column.ID"
value="PERSONID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-map/table"
value="ADRESSE">
</extension>
</field>
.. fields ..
</class>
<class name="AdresseDO"
identity-type="application"
objectid-class="com.elaxy.vamp.dom.person.AdresseDOId"
persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
<extension vendor-name="kodo"
key="jdbc-class-map"
value="base">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-map/table"
value="ADRESSE">
</extension>
<extension vendor-name="kodo"
key="jdbc-sequence-name"
value="ADRESSE_SEQ">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
value="ID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
value="MANDANTID">
</extension>
.. fields ..
</class>
Many thanks,
JanMarc
This is a part of the output from the "schemagen" tool:
<schemas>
<schema name="VAMP">
<table name="ADRESSE">
<pk name="ADRESSE_PRIMARY">
<on column="ID"/>
<on column="MANDANTID"/>
</pk>
<column name="ADRESSART" type="decimal" type-name="NUMBER"
size="5"/>
<column name="EMAIL" type="varchar" type-name="VARCHAR2"
size="30"/>
<column name="FAXNR" type="varchar" type-name="VARCHAR2"
size="25"/>
<column name="ID" type="decimal" type-name="NUMBER"
not-null="true" size="10"/>
<column name="LAND" type="decimal" type-name="NUMBER"
size="10"/>
<column name="MANDANTID" type="decimal" type-name="NUMBER"
not-null="true" size="5"/>
<column name="MELDEADRESSE" type="decimal" type-name="NUMBER"
size="1"/>
<column name="MOBILNR" type="varchar" type-name="VARCHAR2"
size="25"/>
<column name="ORT" type="varchar" type-name="VARCHAR2"
size="30"/>
<column name="PERSONID" type="decimal" type-name="NUMBER"
not-null="true" size="10"/>
<column name="PLZ" type="varchar" type-name="VARCHAR2"
size="5"/>
<column name="POSTADRESSE" type="decimal" type-name="NUMBER"
size="1"/>
<column name="POSTFACH" type="varchar" type-name="VARCHAR2"
size="10"/>
<column name="STRASSE" type="varchar" type-name="VARCHAR2"
size="30"/>
<column name="TELEFONNR" type="varchar" type-name="VARCHAR2"
size="25"/>
<fk name="ADRESSE_PS" delete-action="cascade"
to-table="VAMP.PERSON">
<join column="MANDANTID" to-column="MANDANTID"/>
<join column="PERSONID" to-column="ID"/>
</fk>
<index name="ADRESSE_ORT">
<on column="MANDANTID"/>
<on column="ORT"/>
</index>
<index name="ADRESSE_PLZ">
<on column="MANDANTID"/>
<on column="PLZ"/>
</index>
<index name="ADRESSE_PS">
<on column="MANDANTID"/>
<on column="PERSONID"/>
</index>
<index name="ADRESSE_STR">
<on column="MANDANTID"/>
<on column="STRASSE"/>
</index>
</table>
The foreign key "ADRESSE_PS" was identified correctly.
I've taken a look at the class OracleDictionary and it seems that the
object "ForeignKey" considers only one column from the foreign keys -
but I use foreign keys that include two columns ("MANDANTID", "PERSONID").
Is that right or are foreign keys with two columns allowed by the
OracleDictionary?
Marc Prud'hommeaux wrote:
Jan-
That is odd ... Kodo should be identifying the foreign keys and ordering
the statements accordingly. The mappings appear correct to me at first
glance. If you run the "schemagen" tool, does Kodo correctly identify
the foreign key constraints in the database? Can you post the output
from the command so we can take a look?
Jan-Esdert Franken wrote:
Hi,
i have problems with non-deferred foreing key constraints:
I have a table "PERSON" and a table "ADRESSE" which has a foreign key
to "PERSON". Both tables have primary keys with two columns.
In the mappings I use application identity. The mappings are generated by
xdoclet.
We cannot use deferred constraint because we have to support following
databases: Oracle, Firebird, MS SQL, DB2.
I tested the mappings with Oracle and Firebird and got this exception
(with SQL Trace):
5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (1 errors)>
[15 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
04941 183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751,
(String) Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null,
(String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]
5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
[0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12764,
(int) 1, (int) 0, (null) null, (String) Sylt, (int) 12759, (String) 25980,
(int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
[reused=1]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
[0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
null, (int) 12759, (String) 9999452800, (null) null, (int) 1, (String)
Horstmann, (String) Manfred, (Timestamp) 1959-03-10 00:00:00.381, (String)
Flensburg, (int) 1] [reused=0]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
[0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
04941 183742, (int) 12763, (int) 1, (int) 1, (String) 0171 2846751,
(String) Oldenburg, (int) 12759, (String) 26129, (int) 1, (null) null,
(String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=2]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12762,
(int) 1, (int) 0, (null) null, (String) Sylt, (int) 12760, (String) 25980,
(int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
[reused=3]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
null, (int) 12760, (String) 9999452801, (null) null, (int) 1, (String)
Horstmann, (String) Christine, (Timestamp) 1972-03-10 00:00:00.381,
(String) Erfurt, (int) 1] [reused=1]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
(ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
[params=(int) 0, (null) null, (double) 0.0, (null) null, (int) 12410,
(int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12760,
(int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
null] [reused=0]
5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
[0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
(ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
[params=(int) 0, (null) null, (double) 0.0, (int) 12362, (int) 12378,
(int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12759,
(int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
null] [reused=1]
5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
errors)> [16 ms] rollback
5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
errors)> return
5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
errors)> [0 ms] close
com.solarmetric.jdbc.ReportingSQLException: ORA-02291: integrity
constraint (VAMP.ADRESSE_PS) violated - parent key not found
{prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART, EMAIL, FAXNR,
ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ, POSTADRESSE,
POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?) [params=(int) 1, (String) [email protected], (String) 04941
183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751, (String)
Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null, (String)
Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]} [code=2291,
state=23000]
at
com.solarmetric.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:124)
at
com.solarmetric.jdbc.LoggingConnectionDecorator.access$600(LoggingConnectionDecorator.java:19)
at
com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:728)
at
com.solarmetric.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:362)
How can I force it to insert in the table "NATPERSON" first and then in
the table "ADRESSE"?
I use following JDBC-drivers:
Firebird: 1.5.5
Oracle: 9.2.0.1.0
My property file:
<!-- standard properties for all dbms -->
<prop key="kodo.LicenseKey">LICENSE KEY REMOVED</prop>
<prop key="kodo.ConnectionFactoryProperties">MaxCachedStatements=150,
MaxActive=50, MaxIdle=50</prop>
<prop key="kodo.FetchBatchSize">200</prop>
<prop key="kodo.DataCache">true(CacheSize=5000)</prop>
<prop key="kodo.RemoteCommitProvider">sjvm</prop>
<prop key="kodo.jdbc.MappingFactory">metadata</prop>
<prop key="kodo.jdbc.ForeignKeyConstraints">true</prop>
<prop key="kodo.jdbc.SchemaFactory">native</prop>
<prop
key="javax.jdo.PersistenceManagerFactoryClass">kodo.jdbc.runtime.JDBCPersistenceManagerFactory</prop>
<prop key="javax.jdo.option.Optimistic">true</prop>
<!-- oracle connection properties -->
<prop key="kodo.jdbc.DBDictionary">oracle</prop>
<prop
key="javax.jdo.option.ConnectionDriverName">oracle.jdbc.driver.OracleDriver</prop>
<prop key="javax.jdo.option.ConnectionURL">..</prop>
<prop key="javax.jdo.option.ConnectionUserName">..</prop>
<prop key="javax.jdo.option.ConnectionPassword">..</prop>
<prop key="kodo.jdbc.SequenceFactory">native</prop>
<prop key="kodo.jdbc.Schemas">..</prop>
<!-- firebird connection properties
<prop key="kodo.jdbc.DBDictionary">kodo.jdbc.sql.FirebirdDictionary</prop>
<prop
key="javax.jdo.option.ConnectionDriverName">org.firebirdsql.jdbc.FBDriver</prop>
<prop key="javax.jdo.option.ConnectionURL">..</prop>
<prop key="javax.jdo.option.ConnectionUserName">..</prop>
<prop key="javax.jdo.option.ConnectionPassword">..</prop>
<prop key="kodo.jdbc.SequenceFactory">native(TableName=SYSDUAL,
Format="SELECT GEN_ID(,1) FROM ")</prop>
-->
My database schema looks like this:
TABLE PERSON
FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
FIELD ID (AUTOINC COMMENT (""))
FIELD TYP (SMALLINT REQUIRED COMMENT (""))
FIELD KUNDENNR (CHAR(15) COMMENT ("Kundennummer"))
PRIMARY KEY
FIELD MANDANTID
FIELD ID
FOREIGN KEY MD
TABLE MANDANT
FIELD MANDANTID
INDEX KDNR
FIELD MANDANTID
FIELD KUNDENNR
UNIQUE
TABLE ADRESSE
FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
FIELD ID (AUTOINC COMMENT (""))
FIELD PERSONID (LONGINT REQUIRED COMMENT (""))
PRIMARY KEY
FIELD MANDANTID
FIELD ID
FOREIGN KEY PS
TABLE PERSON
FIELD MANDANTID
FIELD PERSONID
My metadata looks like this:
<class name="PersonDO"
identity-type="application"
objectid-class="com.elaxy.vamp.dom.person.PersonDOId"
persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
<extension vendor-name="kodo"
key="jdbc-class-ind"
value="metadata-value">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-ind/column"
value="TYP">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-ind-value"
value="-1">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-map"
value="base">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-map/table"
value="PERSON">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
value="ID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
value="MANDANTID">
</extension>
<field name="kundenNr"
persistence-modifier="persistent">
</field>
<field name="adressen"
persistence-modifier="persistent">
<collection
element-type="com.elaxy.vamp.dom.person.AdresseDO">
</collection>
<extension vendor-name="kodo"
key="jdbc-field-map"
value="one-many">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-map/ref-column.MANDANTID"
value="MANDANTID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-map/ref-column.ID"
value="PERSONID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-map/table"
value="ADRESSE">
</extension>
</field>
.. fields ..
</class>
<class name="AdresseDO"
identity-type="application"
objectid-class="com.elaxy.vamp.dom.person.AdresseDOId"
persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
<extension vendor-name="kodo"
key="jdbc-class-map"
value="base">
</extension>
<extension vendor-name="kodo"
key="jdbc-class-map/table"
value="ADRESSE">
</extension>
<extension vendor-name="kodo"
key="jdbc-sequence-name"
value="ADRESSE_SEQ">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
value="ID">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId"
value="">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
value="value">
</extension>
<extension vendor-name="kodo"
key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
value="MANDANTID">
</extension>
.. fields ..
</class>
Many thanks,
Jan
Marc Prud'hommeaux
SolarMetric Inc. -
Error: Internal error (WWC-00006)
An unexpected error has occurred in pages: ORA-06502: PL/SQL: numeric or value error: character to number conversion error (WWC-44847)
Couldn't save attribute Content_Owner. (WWV-03005)
Couldn't save attribute Content_Author. (WWV-03005)
Hi,
I am getting this error while adding portlets to my page group..any suggestions?
Thanks in advanceNo, This is happening with oracle defined portlets. But , I am also not able to add any navigation page as a portlet to any of my page. Is it any database back up issue? as I am testing something in UAT , in dev environment everything is fine.
-
Publish: dropping index when it is used for foreign key constraint enforcement
Hi,
I'm trying to update a target schema from a reference database via Publish. Among the changes to apply, there's an index that needs to be dropped. Since it's linked to a foreign key constraint, it cannot be deleted unless the foreign key is temporarily dropped
(I saw somewhere that disabling the foreign key should be enough but it doesn't seem to work either).
Since there are other changes to be made on the same table, this foreign key also has to be dropped before the script can delete the table and re-create it. This part of the script is correctly generated. The problem is that this part appears after the 'DROP
INDEX' instruction.
So when generating the update script, SSDT tries to drop the index BEFORE dropping the foreign key. And I can't drop the foreign key in my custom pre-deployment script, otherwise the update script would fail when trying to delete it again.
Shouldn't SSDT be smart enough to drop the constraint before the index? Is it a bug or did I forget to set an option? If it's not a bug, what can I do apart from doing it manually?
Thank you for your helpHi Elsa,
That sounds like a bug. Could you please file a Connect issue for this at
https://connect.microsoft.com/SQLServer/feedback/CreateFeedback.aspx using the category "Developer Tools (SSDT, BIDS, etc.)"? We're trying to track all bugs through
Connect so that you can tell when we have fixed the issue and we can request more information.
A workaround for this issue might be to write a pre-deployment script for your project to drop the foreign key prior to deployment. A pre-deployment script can be added to your project by right-clicking on the
project in solution explorer and then clicking on Add > Script... and selecting Pre-Deployment Script from the list.
Thanks! -
Error while adding attribute to 0material
hello, experts
I've got some errors while adding Z-attribute to 0material as a attribute.
here's a part of the log.
Activate table /BI0/PMATERIAL
Table is not yet classified
/BI0/PMATERIAL: Structure change at field level (DB is adjusted)
Adjust table in DB >>>
sql:
ALTER TABLE "/BI0/PMATERIAL"
ADD ("/BIC/ZMRPTYPE" VARCHAR2 (000002)
DEFAULT ' ' NOT NULL )
ORA-01562: failed to extend rollback segment number
DDL time(___1): .2,144,462 milliseconds
The SQL statement was not executed
Table /BI0/PMATERIAL (Error adjusting the database)
Table /BI0/PMATERIAL was not activated
How could I solve this problem?
Please help.
thx.Hi,
You can also to Tcode:RSRV
Tests in Tran RSRV
->All elementary Test
>Master Data
>Compare Charat Values in SID-,P- andQ- Tables.
Drag that in right panel.
Open that > in right panel and Entry 0MATERIAL.Transfer
Then Execute->Yes in pop-up.
If any problem..click on repair.
Hope this helps....
Regards,
San! -
Foreign Key Constraint Failure on Self-Referencing Table
In a recent data deletion project, I ran into a problem where Oracle allowed for a record (the parent) to be deleted when there still existed a child record in the same table which referred to the parent.
An abbreviated version of the table is as follows:
create table test (
template_id number not null,
customer_id number null,
parent_id number null,
constraint pk_test primary key (template_id),
constraint r_parent foreign key (parent_id) references test (template_id));
The parent and child records are as follows:
Parent: template_id = 100, customer_id = 200, parent_id = null
Child: template_id = 101, customer_id = null, parent_id = 100
Records were deleted from this table using:
DELETE FROM test WHERE customer_id = 200;
When this statement is executed, is it being executed as part of 155 delete statements using PL/SQL, and tens of thousands of records from 155 tables are being deleted. These delete statements have been ordered taking into account foreign key constraints. All 155 statements are being deleted in a single transaction. The delete statement above was the 23rd statement of the set to be executed. I would have expected when this delete statement was executed, an error would have been thrown. However, all 155 delete statements successfully complete, and after committing the results, the child record above still exists in the DB as an orphan. I also tried executing the first 23 statements manually in SQL*Plus (still one transaction), and the problem still occurs: the parent is deleted and the child is orphaned.
If I execute the very simple example above, I do indeed get an referential constraint error.
Has anyone ever encountered this situation? And does anyone have any ideas how to go about troubleshooting this problem. We need to know the cause of this, as we have a small handful of table with a similar self-referential foreign key constraint set-up.
Thank you very much in advance,
MarkFirst of all, the very simple example that I outlined above I have already tried and it worked: when I attempted to delete the parent a referential integrity error was thrown as one would expect. This small example was my test case to see if I could reproduce what I'm seeing in our application in a more manageable and demonstrable example. But as it worked, I'm still perplexed in reconciling the differences between what I'm seeing in our application (which I can't demonstrate in this help group) and the test case. When I used the test case in my first posting in this thread, I used it to help describe the problem I'm encountered, even though that small example works.
Below is more of the table you've asked for.
OWNER CONSTRAINT_NAME CONSTRAINT_TYPE TABLE_NAME SEARCH_CONDITION R_OWNER R_CONSTRAINT_NAME DELETE_RULE STATUS DEFERRABLE DEFERRED VALIDATED GENERATED BAD RELY LAST_CHANGE INDEX_OWNER INDEX_NAME INVALID VIEW_RELATED
"DOCPADMIN" "R_TEMPLATE_PARENT" "R" "DCR_TEMPLATE" (null) "DOCPADMIN" "XPKDCR_TEMPLATE" "NO ACTION" "ENABLED" "NOT DEFERRABLE" "IMMEDIATE" "VALIDATED" "USER NAME" (null) (null) "2010-01-13 19:01:21" (null) (null) (null) (null)
"DOCPADMIN" "XPKDCR_TEMPLATE" "P" "DCR_TEMPLATE" (null) (null) (null) (null) "ENABLED" "NOT DEFERRABLE" "IMMEDIATE" "VALIDATED" "USER NAME" (null) (null) "2010-01-13 15:48:31" (null) "XPKDCR_TEMPLATE" (null) (null)Overall, I haven't said that Oracle's FK mechanism is broken. What I've said is that I've got a situation that I'm trying to understand. My first attempt at my test case didn't work because the test case worked as it should. I'm trying to figure out another course of action to try and figure this situation out.
Maybe you are looking for
-
Can't view project once compiled.
I am converting from Winhelp (RH8) to Webhelp (RH9). I have imported and I can see the imported word document from the Winhelp project, but once I compile and go to view it I get a blank page. I am using Word 2003. Anyone have an idea why I can't
-
Add Link to 3D Object in 9 Extended
I have been looking everywhere for info on adding a hyperlink to a 3D object in Acrobat 9 Extended to no avail. Any ideas on how to add a link so that when a user clicks on an object or group of objects it will open a browser to a predefined page? Se
-
Huge Time Machine Backups?
Greetings! Why is Time Machine backing up over 31 GB of data every backup? On my MBP, I have about 70 GB of data and every single backup since Oct 26 has been for over 31 GB!!! I only plug in the USB hard drive (backup) once at night, so that's one b
-
Hello, I can't take export backup as it ends up with a message column name invalid.How to solve the problem. My database is on UNIXWARE 7.1.1 & Oracle8i. D ROY SHILLONG- INDIA
-
Hi I have seen some FM <b>"PRC_INT_ITEM_UPDATE"</b> which make osme RFC Commands call like <b>"spc_change_item"</b> with some imports , exports & Table . For "spc_change_item" corresponding java Name is CreateItem which is located in com\sap\spc\