Subject Re: [firebird-support] Division by zero chech
Author Adomas Urbanavicius
Or :
Insert Into MyTable (MyField1, MyField2) Values (Gen_ID(My_Generator, 1), 1/NULLIF(X,0));

NULLIF(X,0) - will give NULL if x = 0, else x;
1/NULL - will give null;




Jason Dodson wrote:

>You need to check for conditions yourself in the first place. Take the following
>statement for instance:
>
>Insert Into MyTable (MyField1, MyField2) Values (Gen_ID(My_Generator, 1), 1/X);
>
>If X = 0, then you will get an error. Instead, write it like this:
>
>If (X = 0) Then
>Begin
> Insert Into MyTable (MyField1, MyField2) Values (Gen_ID(My_Generator, 1), NULL);
>End Else Begin
> Insert Into MyTable (MyField1, MyField2) Values (Gen_ID(My_Generator, 1), 1/X);
>End
>
>
>
>majstoru wrote:
>
>
>>Hi,
>>
>>Does Firebird have a solution to check divizion by zero error?
>>I have SP that update one table with some math operation with data
>>from another table, when source table still have a records which will
>>be generated divizion by zero, I cna't check this by SP code!
>>
>>Thanks
>>
>>
>>
>>
>
>--
>The information transmitted herewith is sensitive information intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
>
>
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Visit http://firebird.sourceforge.net and click the Resources item
>on the main (top) menu. Try Knowledgebase and FAQ links !
>
>Also search the knowledgebases at http://www.ibphoenix.com
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
>
>