Subject | AW: [firebird-support] Big problem trigger |
---|---|
Author | Olaf Kluge |
Post date | 2009-07-16T13:39:20Z |
Hello Anderson
Here is the complete ddl
___________________________
/* Tabelle: TANGEBOTPOS */
CREATE TABLE TANGEBOTPOS (
TEILENR VARCHAR (8) CHARACTER SET ISO8859_1 NOT NULL COLLATE DE_DE,
MENGE DOUBLE PRECISION,
JAHR INTEGER NOT NULL,
NR INTEGER NOT NULL,
VKPREIS DOUBLE PRECISION,
LIEFERDATUM TIMESTAMP,
ID INTEGER NOT NULL,
INFO INTEGER,
POS INTEGER,
PREISBER INTEGER);
/* Primary keys definition */
ALTER TABLE TANGEBOTPOS ADD CONSTRAINT PK_TANGEBOTPOS PRIMARY KEY (ID);
/* Foreign keys definition */
ALTER TABLE TANGEBOTPOS ADD CONSTRAINT FK_TANGEBOTPOS FOREIGN KEY (JAHR, NR)
REFERENCES TANGEBOTE (JAHR, NR) ON UPDATE CASCADE;
ALTER TABLE TANGEBOTPOS ADD CONSTRAINT FK_TANGEBOTPOS1 FOREIGN KEY (TEILENR)
REFERENCES TTEILE (TEILENR) ON DELETE CASCADE ON UPDATE CASCADE;
/* Indices definition */
CREATE INDEX FK_TANGEBOTPOS ON TANGEBOTPOS (JAHR, NR);
CREATE INDEX FK_TANGEBOTPOS1 ON TANGEBOTPOS (TEILENR);
CREATE UNIQUE INDEX PK_TANGEBOTPOS ON TANGEBOTPOS (ID);
SET TERM ^ ;
/* Triggers definition */
/* Trigger: TANGEBOTPOS_BI */
CREATE TRIGGER TANGEBOTPOS_BI FOR TANGEBOTPOS ACTIVE
BEFORE INSERT POSITION 0
AS
declare variable stp_anz double precision;
declare variable stp_preis double precision;
declare variable ang_preis double precision;
declare variable kunde integer;
BEGIN
ang_preis = 0;
NEW.ID = GEN_ID(TANGEBOTPOS_ID_GEN, 1);
if(new.vkpreis is null) then
begin
for select vanz, preis from tstaffelpreise where teilenr = new.teilenr
order by vanz asc into :stp_anz, :stp_preis do
begin
if(new.menge >= :stp_anz) then ang_preis = stp_preis;
else break;
end
if(ang_preis = 0) then begin
select kundennr from tangebote where jahr = new.jahr and nr =
new.nr into :kunde;
select preis from tartkunde
where teilenr = new.teilenr and kundennr = :kunde into :ang_preis;
end
if((ang_preis is null)or(ang_preis = 0)) then
begin
select vkpreis from tteile where teilenr = new.teilenr into :ang_preis;
end
new.vkpreis = :ang_preis;
end
END
^
/* Trigger: TANGEBOTPOS_BU */
CREATE TRIGGER TANGEBOTPOS_BU FOR TANGEBOTPOS ACTIVE
BEFORE UPDATE POSITION 0
AS
declare variable stp_anz double precision;
declare variable stp_preis double precision;
declare variable ang_preis double precision;
declare variable kunde integer;
BEGIN
ang_preis = 0;
if((new.teilenr <> old.teilenr) or (new.vkpreis is null)) then
begin
for select vanz, preis from tstaffelpreise where teilenr = new.teilenr
order by vanz asc into :stp_anz, :stp_preis do
begin
if(new.menge >= :stp_anz) then ang_preis = stp_preis;
else break;
end
if(ang_preis = 0) then begin
select kundennr from tangebote where jahr = new.jahr and nr =
new.nr into :kunde;
select preis from tartkunde
where teilenr = new.teilenr and kundennr = :kunde into :ang_preis;
end
if((ang_preis is null)or(ang_preis = 0)) then
begin
select vkpreis from tteile where teilenr = new.teilenr into :ang_preis;
end
new.vkpreis = :ang_preis;
end
END
^
SET TERM ; ^
____________________________________
There is no other trigger on this table.
Regards.
________________________________
Von: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] Im Auftrag von Anderson Farias
Gesendet: Donnerstag, 16. Juli 2009 15:31
An: firebird-support@yahoogroups.com
Betreff: Re: [firebird-support] Big problem trigger
Hi,
other *before update* triggers on this table with position equal to or
greater than this "problem" trigger
Regards,
Anderson Farias
Checked by AVG - www.avg.com
Version: 8.5.375 / Virus Database: 270.13.16/2241 - Release Date: 07/16/09
05:58:00
Here is the complete ddl
___________________________
/* Tabelle: TANGEBOTPOS */
CREATE TABLE TANGEBOTPOS (
TEILENR VARCHAR (8) CHARACTER SET ISO8859_1 NOT NULL COLLATE DE_DE,
MENGE DOUBLE PRECISION,
JAHR INTEGER NOT NULL,
NR INTEGER NOT NULL,
VKPREIS DOUBLE PRECISION,
LIEFERDATUM TIMESTAMP,
ID INTEGER NOT NULL,
INFO INTEGER,
POS INTEGER,
PREISBER INTEGER);
/* Primary keys definition */
ALTER TABLE TANGEBOTPOS ADD CONSTRAINT PK_TANGEBOTPOS PRIMARY KEY (ID);
/* Foreign keys definition */
ALTER TABLE TANGEBOTPOS ADD CONSTRAINT FK_TANGEBOTPOS FOREIGN KEY (JAHR, NR)
REFERENCES TANGEBOTE (JAHR, NR) ON UPDATE CASCADE;
ALTER TABLE TANGEBOTPOS ADD CONSTRAINT FK_TANGEBOTPOS1 FOREIGN KEY (TEILENR)
REFERENCES TTEILE (TEILENR) ON DELETE CASCADE ON UPDATE CASCADE;
/* Indices definition */
CREATE INDEX FK_TANGEBOTPOS ON TANGEBOTPOS (JAHR, NR);
CREATE INDEX FK_TANGEBOTPOS1 ON TANGEBOTPOS (TEILENR);
CREATE UNIQUE INDEX PK_TANGEBOTPOS ON TANGEBOTPOS (ID);
SET TERM ^ ;
/* Triggers definition */
/* Trigger: TANGEBOTPOS_BI */
CREATE TRIGGER TANGEBOTPOS_BI FOR TANGEBOTPOS ACTIVE
BEFORE INSERT POSITION 0
AS
declare variable stp_anz double precision;
declare variable stp_preis double precision;
declare variable ang_preis double precision;
declare variable kunde integer;
BEGIN
ang_preis = 0;
NEW.ID = GEN_ID(TANGEBOTPOS_ID_GEN, 1);
if(new.vkpreis is null) then
begin
for select vanz, preis from tstaffelpreise where teilenr = new.teilenr
order by vanz asc into :stp_anz, :stp_preis do
begin
if(new.menge >= :stp_anz) then ang_preis = stp_preis;
else break;
end
if(ang_preis = 0) then begin
select kundennr from tangebote where jahr = new.jahr and nr =
new.nr into :kunde;
select preis from tartkunde
where teilenr = new.teilenr and kundennr = :kunde into :ang_preis;
end
if((ang_preis is null)or(ang_preis = 0)) then
begin
select vkpreis from tteile where teilenr = new.teilenr into :ang_preis;
end
new.vkpreis = :ang_preis;
end
END
^
/* Trigger: TANGEBOTPOS_BU */
CREATE TRIGGER TANGEBOTPOS_BU FOR TANGEBOTPOS ACTIVE
BEFORE UPDATE POSITION 0
AS
declare variable stp_anz double precision;
declare variable stp_preis double precision;
declare variable ang_preis double precision;
declare variable kunde integer;
BEGIN
ang_preis = 0;
if((new.teilenr <> old.teilenr) or (new.vkpreis is null)) then
begin
for select vanz, preis from tstaffelpreise where teilenr = new.teilenr
order by vanz asc into :stp_anz, :stp_preis do
begin
if(new.menge >= :stp_anz) then ang_preis = stp_preis;
else break;
end
if(ang_preis = 0) then begin
select kundennr from tangebote where jahr = new.jahr and nr =
new.nr into :kunde;
select preis from tartkunde
where teilenr = new.teilenr and kundennr = :kunde into :ang_preis;
end
if((ang_preis is null)or(ang_preis = 0)) then
begin
select vkpreis from tteile where teilenr = new.teilenr into :ang_preis;
end
new.vkpreis = :ang_preis;
end
END
^
SET TERM ; ^
____________________________________
There is no other trigger on this table.
Regards.
________________________________
Von: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] Im Auftrag von Anderson Farias
Gesendet: Donnerstag, 16. Juli 2009 15:31
An: firebird-support@yahoogroups.com
Betreff: Re: [firebird-support] Big problem trigger
Hi,
> The same trigger I have created as update-trigger to change the price ifRe-check trigger code (you did not post it complete) and... look for any
> the
> part-no. (teilenr) or amaount is changed.
>
> Now, I need to set the field "preisber" with the value 1 (if price model
> one
> set the price), 2 (if price model two) or 3 if price model three)
>
> But it does not work. No matter if I set another value in the trigger, the
> value doensn't change.
other *before update* triggers on this table with position equal to or
greater than this "problem" trigger
Regards,
Anderson Farias
Checked by AVG - www.avg.com
Version: 8.5.375 / Virus Database: 270.13.16/2241 - Release Date: 07/16/09
05:58:00