Subject Re: [IBO] Lookupcombobox question
Author Johan Kotze
Helen

>
> Does the model name in the parent data set continue unchanged after
you refresh it?
Yes, nothing in the parent dataset changes.


> You mentioned that you have a foreign key relationship between
MODEL and STOCK. In which direction does this relationship run?
Would you please post the ddl statement where this constraint is
declared?

/* Domain definitions */
CREATE DOMAIN "D_AMOUNT" AS NUMERIC(10, 2);
CREATE DOMAIN "D_BOOLEAN" AS CHAR(1)
DEFAULT 'F'
CHECK (VALUE IN ('T', 'F')) NOT NULL;
CREATE DOMAIN "D_CLASS" AS INTEGER;
CREATE DOMAIN "D_DATUM" AS DATE;
CREATE DOMAIN "D_DEPNUMBER" AS CHAR(7);
CREATE DOMAIN "D_INDEKS" AS INTEGER;
CREATE DOMAIN "D_INVNUM" AS VARCHAR(20);
CREATE DOMAIN "D_LOCATION" AS VARCHAR(50);
CREATE DOMAIN "D_MODEL" AS VARCHAR(50);
CREATE DOMAIN "D_NOTES" AS VARCHAR(200);
CREATE DOMAIN "D_SERIALNUM" AS VARCHAR(20);
CREATE DOMAIN "D_STATUS" AS VARCHAR(15);
CREATE DOMAIN "D_CLASS" AS INTEGER;
CREATE DOMAIN "D_PRODUCT" AS VARCHAR(20);

/* Table: STOCK, Owner: SYSDBA */

CREATE TABLE "STOCK"
(
"SERIALNR" "D_SERIALNUM" NOT NULL,
"LOCATION" "D_LOCATION" NOT NULL,
"FLOOR" VARCHAR(5),
"DEPARTMENT" "D_DEPNUMBER" NOT NULL,
"INVOICE" "D_INVNUM",
"INSTALLED" "D_DATUM",
"RENTED" "D_BOOLEAN",
"RENTALAMOUNT" "D_AMOUNT",
"STATUS" "D_STATUS" NOT NULL,
"NOTES" "D_NOTES",
"MODEL" "D_MODEL" NOT NULL,
"GEBRUIKER_IDX" "D_INDEKS" NOT NULL,
"CLASS" "D_CLASS" NOT NULL,
CONSTRAINT "PK_STOCK" PRIMARY KEY ("SERIALNR")
);
ALTER TABLE "STOCK" ADD CONSTRAINT "FK_STOCK_CLASS" FOREIGN KEY
("CLASS") REFERENCES CLASSES ("INDEKS");
ALTER TABLE "STOCK" ADD CONSTRAINT "FK_STOCK_DEP" FOREIGN KEY
("DEPARTMENT") REFERENCES DEPARTMENTS ("DEPNUMBER") ON UPDATE CASCADE;
ALTER TABLE "STOCK" ADD CONSTRAINT "FK_STOCK_GEBRUIKER" FOREIGN KEY
("GEBRUIKER_IDX") REFERENCES GEBRUIKERS ("INDEKS");
ALTER TABLE "STOCK" ADD CONSTRAINT "FK_STOCK_LOCATION" FOREIGN KEY
("LOCATION") REFERENCES LOCATIONS ("LOCATION") ON UPDATE CASCADE;
ALTER TABLE "STOCK" ADD CONSTRAINT "FK_STOCK_MODEL" FOREIGN KEY
("MODEL") REFERENCES MODELS ("MODELNAME") ON UPDATE CASCADE;
ALTER TABLE "STOCK" ADD CONSTRAINT "FK_STOCK_STATUS" FOREIGN KEY
("STATUS") REFERENCES STATUSES ("STATLEVEL");
SET TERM ^ ;


/* Triggers only will work for SQL triggers */

CREATE TRIGGER "STOCK_CLASS_INSERT" FOR "STOCK"
ACTIVE BEFORE INSERT POSITION 0
AS
DECLARE VARIABLE C INTEGER;
BEGIN
SELECT CLASS FROM MODELS WHERE MODELS.MODELNAME=NEW.MODEL INTO :C;
NEW.CLASS=C;
END
^

CREATE TRIGGER "STOCK_CLASS_UPDATE" FOR "STOCK"
ACTIVE BEFORE UPDATE POSITION 0
AS
DECLARE VARIABLE C INTEGER;
BEGIN
SELECT CLASS FROM MODELS WHERE MODELS.MODELNAME=NEW.MODEL INTO :C;
NEW.CLASS=C;
END
^


/* Table: MODELS, Owner: SYSDBA */

CREATE TABLE "MODELS"
(
"MODELNAME" "D_MODEL" NOT NULL,
"PRODUCT" "D_PRODUCT" NOT NULL,
"NOTES" "D_NOTES",
"CLASS" "D_CLASS" NOT NULL,
CONSTRAINT "PK_MODELS" PRIMARY KEY ("MODELNAME")
);
ALTER TABLE "MODELS" ADD CONSTRAINT "FK_MODELS" FOREIGN KEY
("PRODUCT") REFERENCES PRODUCT ("DESCRIPTION");
ALTER TABLE "MODELS" ADD CONSTRAINT "FK_MODELS_CLASS" FOREIGN KEY
("CLASS") REFERENCES CLASSES ("INDEKS");
SET TERM ^ ;


/* Triggers only will work for SQL triggers */

CREATE TRIGGER "MODEL_CLASS_INSERT" FOR "MODELS"
ACTIVE BEFORE INSERT POSITION 0
AS
DECLARE VARIABLE C INTEGER;
BEGIN
SELECT CLASS FROM PRODUCT WHERE PRODUCT.DESCRIPTION=NEW.PRODUCT
INTO :C;
NEW.CLASS=C;
END
^

CREATE TRIGGER "MODEL_CLASS_UPDATE" FOR "MODELS"
ACTIVE BEFORE UPDATE POSITION 0
AS
DECLARE VARIABLE C INTEGER;
BEGIN
SELECT CLASS FROM PRODUCT WHERE PRODUCT.DESCRIPTION=NEW.PRODUCT
INTO :C;
NEW.CLASS=C;
END
^


> Which query component class are you using for the datasets?
Both the parent and the lookup datasets are TIB_Query.

If you are interested I can E-Mail you my application and the
database. It is about 8Mb total.

Regards

Johan Kotze