Subject | Re: Wrong calculations inside trigger |
---|---|
Author | wojciech_materna |
Post date | 2003-05-12T09:41Z |
--- In ib-support@yahoogroups.com, "Alan McDonald" <alan@m...> wrote:
but not all the time.
in which record is inserting. Values from new. - are using to
calculate proper values to change in another table, from which I take
few values by select.
Insert in table (name starting with G - documents) and update in
table (name starting with M - list of items)
Wojtek
> Why aren't you doing this before insert with all the new values?New. after insert exists. Big problem is, that my trigger works,
> not sure but does after insert have the "new" context variables?
but not all the time.
> In any case I would do it all before insert and before update, thenI would
> not be updating the record again, just assigning the new calculatedvalues
> which depend on the known inserted valuesnew
> You also do not need to select anything since you will have all the
> values at hand in their new. context without having to select.So, it is true, but I have to change values in other table than table
>
> Alan
in which record is inserting. Values from new. - are using to
calculate proper values to change in another table, from which I take
few values by select.
Insert in table (name starting with G - documents) and update in
table (name starting with M - list of items)
Wojtek
>hour,
> > -----Original Message-----
> > From: Wojciech Materna [mailto:szef@t...]
> > Sent: Monday, 12 May 2003 6:18 PM
> > To: ib-support@yahoogroups.com
> > Subject: [ib-support] Wrong calculations inside trigger
> >
> >
> > Fiesta
> > I have problem in bad calculations inside trigger.
> > We use:
> > Server : Linux RedHat 7.2, IB 6.0.1, on 1.2GHz PIII, 512MB RAM,
> > 2xHDD SCSI,
> > GDB size about 600MB, 15 connected users, many transactions every
> >calculate
> > trigger after insert have to update cost of item, so if it can't
> > properly all is wrong, tragedy etc.M9003 WHERE
> >
> > trigger body (partial):
> >
> > ALTER TRIGGER NG90035
> > AFTER INSERT
> > POSITION 0
> > AS
> > DECLARE VARIABLE STANW DECIMAL(18,3);
> > DECLARE VARIABLE STANI DECIMAL(18,3);
> > DECLARE VARIABLE CENANOWA DECIMAL(18,3);
> > DECLARE VARIABLE CENASTARA DECIMAL(18,3);
> > BEGIN
> > IF (NEW.STRONA=1) THEN
> > BEGIN
> > SELECT SP_WI+ON_WI-ON_MI,(SP_WI+ON_WI-ON_MI)*CENA,CENA FROM
> > M9003.INDEKS=NEW.INDEKS(STANI+NEW.ILOSC);
> > INTO :STANI,:STANW,:CENASTARA;
> > IF (STANI+NEW.ILOSC>0.0) THEN
> > CENANOWA=(STANW+NEW.ILOSC*NEW.CENA)/
> > /* here!!!*/WHERE
> > ELSE
> > CENANOWA=NEW.CENA;
> > UPDATE M9003 SET ON_WI=ON_WI+NEW.ILOSC,CENA=:CENANOWA
> > M9003.INDEKS=NEW.INDEKS;numer of
> > END
> > ..............
> > rest is not interesting
> >
> > So:
> > in line /* here!!!*/
> > calculation of variable CENANOWA failed - after calculation
> > NEW.ILOSC*NEW.CENA is equal to 0, really it isn't true
> > becouse if I post this values into control table - everytime are
> > not 0 both
> > (they can't be 0). This problems I have noticed when I increase
> > post eventscalculations very
> > from tables, and set in isc_config low value of EVENT_MEM_SIZE.
> > After that, inserts works ok, database ok, etc. byt that
> > oftenfrom
> > fails. When I increase this parameter and delete some of events
> > triggers this problem appears not often, but appears.ways and
> > I do everything what I can imagine, change trigger text on many
> > nothing can solve problem.http://docs.yahoo.com/info/terms/
> >
> > Any suggestions very welcome, here, or private szef@t...
> > Wojtek
> >
> >
> >
> >
> >
> > To unsubscribe from this group, send an email to:
> > ib-support-unsubscribe@egroups.com
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> >
> >