Subject Re: [IBO] select view crashes a remote Firebird Server
Author Helen Borrie
At 01:55 PM 31/05/2004 +0000, you wrote:


> > select nullif(0,0)... will return NULL
> > select nullif(3,0)... will return NULL
> > Select nullif(NULL,0) will return zero.
> >
>
>
>I think that it is not true:

Correct, it's not true. -- Sorry!


>In any case, it is not the reason because you can do "select * from
>female" and you will be able to see the list of recors without
>problems. I insist that the detonating is the combination of the 2
>selects. One select alone works ok and never crashes the FB server.

OK, the next thing you'll need to look at is the columns in the SELECT for
the view. You must use aliases on *everything* in joins:

select
h.DtNaixement,
h.Parts,
h.Parts,
h.Comentari,
/* the following three columns */
CurLoc1,
CurLoc2,
CurLoc3,
coalesce(/* this column */ parts,0)+coalesce(/* this column */ iniparity,0),
/* this column */ CurPreWeaneds,

h.Mare,
h.DtEntrada,
h.Genetics,
h.codi,
h.herd_id,

case when /* this column */ dtbaixa is null then 1 else 0 end,

h.lacstatus,
f.lfAbortions,
f.lfliveBorn*1.00 / nullif(h.parts,0),
f.lfStillBorn*1.00 / nullif(h.parts,0),
(f.lfliveBorn+f.lfstillborn+f.lfmummies)*1.00 / nullif(h.parts,0),

/* this column */ lflittersweaned,
f.lfLiveborn,

/* this column */ LFLIVEBORNLITWEANED,

f.lfMummies,
f.lfnetadded,

/* this column */ LfNetFostered,

f.LFPREWEANEDDEATHS,

100.0 - 100.0* /* all of these columns*/
lftotalweaned/nullif(lflivebornlitweaned+lfnetfostered,0),

f.lfServices,
f.lfStillborn,
f.lfliveBorn+f.lfstillborn+f.lfmummies,
h.ubicacio,
h.PMorfo,
h.Name,
h.Registre,
h.DtBaixa,
h.CausaBaixa,
h.TipusBaixa,
h.reproStatus,
h.DtRepro-h.DtNaixement,
h.Pare,
case when /* this column */ peticiorepos='F' then 0 else 1 end,
h.UserFieldA0,
h.UserFieldA1 from herd h
inner join herd_females f on h.herd_id=f.herd_id
where h.htype=0;

Fix up the view and then see whether you can reproduce the problem afterwards.

Helen