TABLE_PRD
CREATE TABLE TABLE_PRD
(
PRODUCT_CODE_PRD VARCHAR2(10) NOT NULL
, DESCRIPTION_PRODUCT_PRD VARCHAR2(20)
, CONSTRAINT TABLE_PRD_PK PRIMARY KEY
(
PRODUCT_CODE_PRD
)
ENABLE
);
INSERT INTO TABLE_PRD (PRODUCT_CODE_PRD, DESCRIPTION_PRODUCT_PRD) VALUES ('LS', 'Leasing');
INSERT INTO TABLE_PRD (PRODUCT_CODE_PRD, DESCRIPTION_PRODUCT_PRD) VALUES ('TG', 'Total Cost');
TABLE_POS
CREATE TABLE TABLE_POS
(
POSITION_CODE_POS INTEGER NOT NULL
, SOME_TEXT_POS VARCHAR2(20)
, CONSTRAINT TABLE_POS_PK PRIMARY KEY
(
POSITION_CODE_POS
)
ENABLE
);
INSERT INTO TABLE_POS (POSITION_CODE_POS, COMMENT_POS) VALUES ('1', 'Owner');
INSERT INTO TABLE_POS (POSITION_CODE_POS, COMMENT_POS) VALUES ('2', 'Manager');
INSERT INTO TABLE_POS (POSITION_CODE_POS, COMMENT_POS) VALUES ('3', 'User');
TABLE_REL
CREATE TABLE TABLE_REL
(
PRODUCT_CODE_REL VARCHAR2(10) NOT NULL
, POSITION_CODE_REL INTEGER NOT NULL
, DESCRIPTION_REL VARCHAR2(20)
, CREATION_DATE_REL DATE
, CONTENT BLOB
, CONSTRAINT TABLE_REL_FK1 FOREIGN KEY (PRODUCT_CODE_REL) REFERENCES TABLE_PRD (PRODUCT_CODE_PRD) ENABLE
, CONSTRAINT TABLE_REL_FK2 FOREIGN KEY (POSITION_CODE_REL) REFERENCES TABLE_POS (POSITION_CODE_POS) ENABLE
, CONSTRAINT TABLE_REL_PK PRIMARY KEY (PRODUCT_CODE_REL, POSITION_CODE_REL) ENABLE
);
INSERT INTO TABLE_REL (PRODUCT_CODE_REL, POSITION_CODE_REL, DESCRIPTION_REL) VALUES ('LS', '1', 'Leasing - Owner');
INSERT INTO TABLE_REL (PRODUCT_CODE_REL, POSITION_CODE_REL, DESCRIPTION_REL) VALUES ('LS', '2', 'Leasing - Manager');
INSERT INTO TABLE_REL (PRODUCT_CODE_REL, POSITION_CODE_REL, DESCRIPTION_REL) VALUES ('LS', '3', 'Leasing - User');
INSERT INTO TABLE_REL (PRODUCT_CODE_REL, POSITION_CODE_REL, DESCRIPTION_REL) VALUES ('TG', '1', 'Total Cost - Owner');
INSERT INTO TABLE_REL (PRODUCT_CODE_REL, POSITION_CODE_REL, DESCRIPTION_REL) VALUES ('TG', '2', 'Total Cost - Manager');
INSERT INTO TABLE_REL (PRODUCT_CODE_REL, POSITION_CODE_REL, DESCRIPTION_REL) VALUES ('TG', '3', 'Total Cost - User');
Теперь мне нужно выполнить циркуляр / раунд SWAP , изменив POSITION_CODE_REL
1 -> 3
(перед 1, 3), 2 -> 1
(перед 2, 1), 3 -> 2
(перед 3 - 2).
6 errors saving changes to table TABLE_REL:
Row 1: ORA-00001: unique constraint (TABLE_REL_PK) violated
Row 2: ORA-00001: unique constraint (TABLE_REL_PK) violated
Row 3: ORA-00001: unique constraint (TABLE_REL_PK) violated
Row 4: ORA-00001: unique constraint (TABLE_REL_PK) violated
Row 5: ORA-00001: unique constraint (TABLE_REL_PK) violated
Row 6: ORA-00001: unique constraint (TABLE_REL_PK) violated
Я знаю, какова ситуация, Вопрос в том, существует ли какая-то процедура для выполнения SWAP ?