MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » October 2012

Re: Pros and Cons of DB defined Referential Integrity Constraints



fixed

The constraint is not a separate object.

CREATE TABLE ROB/CODEFILE
(MYCODE CHAR ( 1) NOT NULL,
MYDESC CHAR ( 20) NOT NULL WITH DEFAULT,
CONSTRAINT CODEFILEPRIMARYKEY PRIMARY KEY (MYCODE))

CREATE TABLE ROB/TRANFILE
(TRANTS TIMESTAMP NOT NULL,
MYCODE CHAR ( 1),
CONSTRAINT TRANTOCODEFILE FOREIGN KEY (MYCODE)
REFERENCES ROB/CODEFILE (MYCODE)
ON DELETE NO ACTION ON UPDATE NO ACTION)

SAVOBJ OBJ(TRANFILE CODEFILE) LIB(ROB) DEV(*SAVF) OBJTYPE(*FILE)
SAVF(ROB/ROB)

RSTOBJ OBJ(TRANFILE CODEFILE) SAVLIB(ROB) DEV(*SAVF) OBJTYPE(*FILE)
SAVF(ROB/ROB)
-->>RSTLIB(ROBDELME)

INSERT INTO ROBDELME/CODEFILE (MYCODE, MYDESC)
VALUES('A','First code')

INSERT INTO ROBDELME/TRANFILE (TRANTS, MYCODE)
VALUES(current timestamp, 'A')

INSERT INTO ROBDELME/TRANFILE (TRANTS, MYCODE)
VALUES(current timestamp, 'B')
Message . . . . : Operation not allowed by referential constraint
TRANTOCODEFILE in ROBDELME.



Rob Berendt





Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact