Subject | Re: Re: [ib-support] How trigger changes can become visible in current Delphi transaction |
---|---|
Author | Hristo Aladjov |
Post date | 2002-11-08T09:57:14Z |
Thanks a lot for your comments and advisees.
The problem is actually that trigger is used to update visual style (text and background color, font style…) of the current row.
CREATE PROCEDURE UpdatePriceListStyle
(OnlyCaption SMALLINT,
Available CHAR,
PublishCurrency SMALLINT,
VAT SMALLINT,
Recommended SMALLINT,
Sale SMALLINT,
Obsolete SMALLINT,
UniqueItem SMALLINT,
Qnt_InStock INTEGER,
Qnt_Ordered INTEGER,
Qnt_Offered INTEGER)
RETURNS (NewStyle INTEGER)
AS
BEGIN
NewStyle = 0;
IF (:Recommended=1) THEN
NewStyle = NewStyle + 128;
IF (:VAT=1) THEN
NewStyle = NewStyle + 64;
IF (:Sale=1) THEN
NewStyle = NewStyle + 32;
IF (:Obsolete=1) THEN
NewStyle = NewStyle + 16;
IF (:OnlyCaption=1) THEN
NewStyle = 16842880;
ELSE
BEGIN
IF (:Qnt_InStock>:Qnt_Offered) THEN
NewStyle = NewStyle + 196608;
ELSE IF ((:Qnt_InStock<:Qnt_Offered) AND (:Qnt_Ordered>:Qnt_Offered-:Qnt_InStock)) THEN
NewStyle = NewStyle + 131072;
ELSE IF ((:Qnt_InStock<:Qnt_Offered) AND (:Qnt_Ordered>=Qnt_Offered-:Qnt_InStock)) THEN
NewStyle = NewStyle + 655360;
ELSE IF ((:Qnt_InStock=0) AND (:Qnt_Ordered>:Qnt_Offered)) THEN
NewStyle = NewStyle + 262144;
ELSE IF ((:Qnt_InStock=0) AND (:Qnt_Ordered=0) AND (:Qnt_Offered>0)) THEN
NewStyle = NewStyle + 393216;
ELSE IF ((:Qnt_InStock=0) AND (:Qnt_Ordered=0) AND (:Qnt_Offered=0)) THEN
NewStyle = NewStyle + 458752;
END
SUSPEND;
END
^
CREATE TRIGGER UpdatePriceListStyle FOR PriceList ACTIVE BEFORE UPDATE POSITION 0 AS
DECLARE VARIABLE Style INTEGER;
BEGIN
EXECUTE PROCEDURE UpdatePriceListStyle new.OnlyCaption, new.Available, new.PublishCurrency, new.VAT, new.Recommended,
new.Sale, new.Obsolete, new.UniqueItem, new.Qnt_InStock, new.Qnt_Ordered, new.Qnt_Offered
RETURNING_VALUES :Style;
new.Style = :Style;
END
^
That is why I wanted to made changes visible as fast as possible without closing the transaction. I think that your suggestion to use CommitRetainig + Refresh of the table will work.
Thank you again for the help
Sincerely Yours,
Hristo Aladjov
-----------------------------------------------------------------
http://chatlisi.globul.bg - Спечели с най-яката игра за chat-кащи !
The problem is actually that trigger is used to update visual style (text and background color, font style…) of the current row.
CREATE PROCEDURE UpdatePriceListStyle
(OnlyCaption SMALLINT,
Available CHAR,
PublishCurrency SMALLINT,
VAT SMALLINT,
Recommended SMALLINT,
Sale SMALLINT,
Obsolete SMALLINT,
UniqueItem SMALLINT,
Qnt_InStock INTEGER,
Qnt_Ordered INTEGER,
Qnt_Offered INTEGER)
RETURNS (NewStyle INTEGER)
AS
BEGIN
NewStyle = 0;
IF (:Recommended=1) THEN
NewStyle = NewStyle + 128;
IF (:VAT=1) THEN
NewStyle = NewStyle + 64;
IF (:Sale=1) THEN
NewStyle = NewStyle + 32;
IF (:Obsolete=1) THEN
NewStyle = NewStyle + 16;
IF (:OnlyCaption=1) THEN
NewStyle = 16842880;
ELSE
BEGIN
IF (:Qnt_InStock>:Qnt_Offered) THEN
NewStyle = NewStyle + 196608;
ELSE IF ((:Qnt_InStock<:Qnt_Offered) AND (:Qnt_Ordered>:Qnt_Offered-:Qnt_InStock)) THEN
NewStyle = NewStyle + 131072;
ELSE IF ((:Qnt_InStock<:Qnt_Offered) AND (:Qnt_Ordered>=Qnt_Offered-:Qnt_InStock)) THEN
NewStyle = NewStyle + 655360;
ELSE IF ((:Qnt_InStock=0) AND (:Qnt_Ordered>:Qnt_Offered)) THEN
NewStyle = NewStyle + 262144;
ELSE IF ((:Qnt_InStock=0) AND (:Qnt_Ordered=0) AND (:Qnt_Offered>0)) THEN
NewStyle = NewStyle + 393216;
ELSE IF ((:Qnt_InStock=0) AND (:Qnt_Ordered=0) AND (:Qnt_Offered=0)) THEN
NewStyle = NewStyle + 458752;
END
SUSPEND;
END
^
CREATE TRIGGER UpdatePriceListStyle FOR PriceList ACTIVE BEFORE UPDATE POSITION 0 AS
DECLARE VARIABLE Style INTEGER;
BEGIN
EXECUTE PROCEDURE UpdatePriceListStyle new.OnlyCaption, new.Available, new.PublishCurrency, new.VAT, new.Recommended,
new.Sale, new.Obsolete, new.UniqueItem, new.Qnt_InStock, new.Qnt_Ordered, new.Qnt_Offered
RETURNING_VALUES :Style;
new.Style = :Style;
END
^
That is why I wanted to made changes visible as fast as possible without closing the transaction. I think that your suggestion to use CommitRetainig + Refresh of the table will work.
Thank you again for the help
Sincerely Yours,
Hristo Aladjov
-----------------------------------------------------------------
http://chatlisi.globul.bg - Спечели с най-яката игра за chat-кащи !