Arc construct,
basic testing of the constraints
(Oracle 12c)


S Binder 2015


<- back to arc code
<- home
/*
    insert some test data: PK columns only
*/
BEGIN
INSERT INTO arc_reftbl1 VALUES (1) ;
INSERT INTO arc_reftbl2 VALUES (2) ;
INSERT INTO arc_reftbl3 VALUES (3) ;
END;
/
/*
    Test the constraints
*/
/*

This INSERT must work

*/
INSERT INTO arc_ VALUES (1,1,NULL,NULL) ;
/*

Trying to execute the previous INSERT _again_
must fail (due to the PK constraint)!

*/
INSERT INTO arc_ VALUES (1,1,NULL,NULL) ;
/*

These INSERTs must fail due to the check constraint.

*/
INSERT INTO arc_ VALUES (2,1,1,1) ;
INSERT INTO arc_ VALUES (2,1,1,NULL) ;
INSERT INTO arc_ VALUES (2,NULL,NULL,NULL) ;
/*

These INSERTs must fail due to the foreign key constraints.
(message: parent key not found)

*/
INSERT INTO arc_ VALUES (3,9,NULL,NULL) ;
INSERT INTO arc_ VALUES (3,NULL,9,NULL) ;
INSERT INTO arc_ VALUES (3,NULL,NULL,9) ;
/*

The following anonymous block must execute
without error messages.

*/
BEGIN
INSERT INTO arc_ VALUES (2, 1, NULL, NULL) ;
INSERT INTO arc_ VALUES (3, NULL, 2, NULL) ;
INSERT INTO arc_ VALUES (4, NULL, NULL, 3) ;
END;
/
/*

Retrieve a list of constraints
used for the ARC construct:

*/
SELECT *
FROM user_constraints
WHERE table_name LIKE 'ARC_%';
Last update 2025-09-22 by SB