Re: Getting data to a file, and divide by zero
Posted in 1995
Topics: Stored Procedures & SPL
For the divide by zero problem, implement decode() as a stored procedure,
then you can write queries like you're used to in Oracle.
I don't know what decode does in Oracle, but if you just want to replace ones
with zeros you could just implement a simple version that does that only.
The syntax is something like:
create procedure decode( x ) returning int;define x int;
if x = 0 then
return 1;
else
return x;
end if
end procedure
Then you can just:
select col1 / decode(col2) from table1... etc. etc.
like you would in Oracle.
Niel M. Bornstein (nbornstein@plr.com) wrote:
: A second question pertains to selecting expressions. Part of my query
: involves dividing two columns, and the divisor may be zero. In Oracle, I
: would use the decode() function to change any zeros in the divisor to ones
: and I know I'd be safe from this problem. Is there an equivalent way to
: do this in Informix?