Subject Re: error in trigger
Author duilio_fos <irel_llc@libero.it>
Milan,

I found the culprit.

The trigger - as you may remember - builds 3 different records (2
only when some conditions are met).

I did many tests, cutting the trigger in parts and feeding part1,
then part1 + part2 etc until I found that part1...partN gave the
error.

So I could be sure that the problem was with partN.

partN just inserts a record in table mv_dg.

Has table mv_dg any trigger ?

No.

Stuck.

Then I could see a very stupid error in one of the table's
constraints:

alter table mv_dg add constraint MV_DG_INVALIDCOD_MAG CHECK (cod_mag=
(SELECT cod_mag FROM mv_hd WHERE
(
(mv_dg.y_mov = mv_dg.y_mov) <-HERE!!
AND
(mv_dg.n_mov = mv_hd.n_mov)
)

The line

mv_dg.y_mov = mv_dg.y_mov

was supposed to be

mv_dg.y_mov = mv_hd.y_mov

As the same value for column n_mov was found also in 2002 data,
the "multiple rows..." error message was raised.

Some bugs can bite you even after 1 year of seemingly smooth work...

Thanks a lot for your kind help

Duilio