Subject Re: Procedure Problem, Div By 0
Author andyh20012003
--- In firebird-support@yahoogroups.com, "Alexander V.Nevsky"
<ded@h...> wrote:
> --- In firebird-support@yahoogroups.com, "andyh20012003"
> <andyholcomb@c...> wrote:
> > CREATE PROCEDURE EACHNODE_NETLIST_2
> > RETURNS (
> > EHTESTEDVAL DOUBLE PRECISION,
> > EHNODE INTEGER,
> > EHSUB INTEGER,
> > EHCIR INTEGER,
> > ELTESTEDVAL DOUBLE PRECISION,
> > ELNODE INTEGER,
> > ELSUB INTEGER,
> > ELCIR INTEGER)
> > AS
> > begin
> > for
> > select ENH.TestedValue,
> > ENH.Node,
> > ENH.SubstrateNum,
> > ENH.CircuitNum,
> > ENL.TestedValue,
> > ENL.Node,
> > ENL.SubstrateNum,
> > ENL.CircuitNum
> >
> > From EachNode ENH, EachNode ENL
> >
> > Where
> > (ENH.JobNum = "2621") and
> > (ENH.ProberNum = 1) and
> > (ENL.JobNum = "2621") and
> > (ENL.ProberNum = 1) and
> > ((ENH.Passed = 1) or (ENL.Passed = 1)) and
> > (ENH.SubstrateNum = ENL.SubstrateNum ) and
> > (ENH.CircuitNum = ENL.CircuitNum) and
> > (ENH.Node = 2) and
> > (ENL.Node = 92) and
> > (
> > ((ENH.TestedValue != 0) and (ENL.TestedValue != 0))
> > and
> > (
> > ((ENH.TestedValue/ENL.TestedValue)>0 ) and
> > ( (100 -((ENH.TestedValue/ENL.TestedValue)
> > *100)) > (100 - 98))
> > or(
> > (ENL.TestedValue/ENH.TestedValue)>0 ) and
> > ( (100 -((ENL.TestedValue/ENH.TestedValue)
> > *100)) > (100 - 98))
> > )
> > )
> >
> >
> >
Into :EHTestedval, :EHNode, :EHSub, :EHCir, :ELTestedVal, :ELNode,
> :E
> > LSub, :ELCir
> >
> > do suspend;
> > end
>
> Andy, IB/FB perform complete boolean evaluation (all conditions
are
> always calcualted even if it is clear already will result be true
or
> false), so your

I thought something like this was the case.



>
> (ENH.TestedValue != 0) and (ENL.TestedValue != 0)
>
> don't protect you from division by zero in next condition. I can
> suggest to remove check for 2% accuracy from query and make this
> inside loop execution, something like
>
> For Select
> ...
> Do
> if ((EHTestedVal<>0) And (ELTestedVal<>0))
> then
> if ((((EHTestedVal/ELTestedVal)>0) and
> ((100 -(EHTestedVal/ELTestedVal)*100) > 2)
> )
> Or
> (((ELTestedVal/EHTestedVal)>0) and
> ((100 -(ELTestedVal/EHTestedVal)*100) > 2)
> )
> then
> Suspend;
>

This will be my first time for if thens, I will mess with it and see
what happens


> BTW, seems your TestedValue is Double Precision, and compare it
with
> 0 is incorrect, I recommend to use as precision value which can be
> treated as zero for your application, like
>
> if ((Abs(EHTestedVal)>PrecVal) And (Abs(ELTestedVal)>PrecVal))

This happened when I copied the tables from the paradox tables,
would I be better off changing them to float?

>
> I don't remember have IB5 UDF ABS or not, if not you can write
own

IB5 doesnt like Abs

> or use BETWEEN -PrecVal And PrecVal.

Can you give me a example of this, Please

>
> Best regards, Alexander.



Thank you
Andy