Subject Re: [ib-support] Re: Database corruption after alter table
Author Carsten Schäfer
----- Original Message -----
From: "Thomas Steinmaurer" <ts@...>
To: <ib-support@yahoogroups.com>
Sent: Thursday, March 06, 2003 2:13 PM
Subject: RE: [ib-support] Re: Database corruption after alter table


> Hi Carsten,
>

>
> Any chance that there is a trigger or updateable foreign key
> constraint, which gets fired when the table is updated again,
> so that T_ERGEBNIS is in a restoreable state then?
>
> What is the full DDL of T_ERGEBNIS, T_EINFACHANGEBOT including
> triggers?
>

Both tables have a reference to t_mitarbeiter.
(but all of my tables have a reference to it)

This is the ddl;


SET SQL DIALECT 3;

CREATE GENERATOR GEN_ERGEBNIS;
SET NAMES WIN1252;


CREATE TABLE T_ERGEBNIS (
ID_ERGEBNIS INTEGER NOT NULL,
F_ID_WERKSTOFF INTEGER NOT NULL,
F_ID_WARM INTEGER NOT NULL,
F_KH_EINHEIT VARCHAR(5),
F_KH_VON DOUBLE PRECISION,
F_KH_BIS DOUBLE PRECISION,
F_TIEFE_VON DOUBLE PRECISION,
F_TIEFE_BIS DOUBLE PRECISION,
F_ACTIVE INTEGER,
F_ID_MA_ACT INTEGER,
F_RC_VON DOUBLE PRECISION,
F_RH_VON DOUBLE PRECISION,
F_RH_BIS DOUBLE PRECISION,
F_GH_VON DOUBLE PRECISION,
F_GH_BIS DOUBLE PRECISION,
F_DEACTIVATION DATE,
F_RH_EINHEIT VARCHAR(5),
F_GH_EINHEIT VARCHAR(5),
F_RC_BIS DOUBLE PRECISION DEFAULT -1,
F_RC_TIEFE_VON DOUBLE PRECISION DEFAULT -1,
F_RC_TIEFE_BIS DOUBLE PRECISION DEFAULT -1
);


ALTER TABLE T_ERGEBNIS ADD PRIMARY KEY (ID_ERGEBNIS);


ALTER TABLE T_ERGEBNIS ADD CONSTRAINT ERGMIT FOREIGN KEY (F_ID_MA_ACT) REFERENCES T_MITARBEITER (ID_MITARBEITER) ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE T_ERGEBNIS ADD CONSTRAINT ERGWARM FOREIGN KEY (F_ID_WARM) REFERENCES T_WARMBEHANDLUNG (ID_WARMBEHANDLUNG) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE T_ERGEBNIS ADD CONSTRAINT ERGWERK FOREIGN KEY (F_ID_WERKSTOFF) REFERENCES T_WERKSTOFF (ID_WERKSTOFF) ON DELETE CASCADE ON UPDATE NO ACTION;


CREATE INDEX IND_ERGEBNIS_TIEFE_BIS ON T_ERGEBNIS (F_TIEFE_BIS);
CREATE INDEX IND_ERGEBNIS_TIEFE_VON ON T_ERGEBNIS (F_TIEFE_VON);



SET TERM ^ ;




CREATE TRIGGER TR_ERGEBNIS FOR T_ERGEBNIS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
NEW.id_ergebnis = GEN_ID(gen_ergebnis, 1);
END
^


SET TERM ; ^


CREATE TABLE T_EINFACHANGEBOT (
F_ID_ANGEBOT INTEGER NOT NULL,
F_BETREFF VARCHAR(100),
F_ANREDE VARCHAR(100),
F_BLOCK1 VARCHAR(3000),
F_BLOCK2 VARCHAR(4700),
F_BLOCK3 VARCHAR(4700),
F_ID_MA_BELEG INTEGER NOT NULL
);

ALTER TABLE T_EINFACHANGEBOT ADD PRIMARY KEY (F_ID_ANGEBOT);


ALTER TABLE T_EINFACHANGEBOT ADD CONSTRAINT EA_MA_BELEG FOREIGN KEY (F_ID_MA_BELEG) REFERENCES T_MITARBEITER (ID_MITARBEITER) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE T_EINFACHANGEBOT ADD CONSTRAINT EINFACHANG2ANG FOREIGN KEY (F_ID_ANGEBOT) REFERENCES T_ANGEBOT (ID_ANGEBOT) ON DELETE CASCADE ON UPDATE NO ACTION;