Subject | Re: [firebird-support] Case statement returns null |
---|---|
Author | jft |
Post date | 2008-09-19T23:52:39Z |
Hi!
This comment is totally OT to your original question relating to code erroneously producing nulls.
An alternative approach you may find interesting is to define IN_OUT as:
IN_OUT smallint default 1 check(value in (1,-1))
This can simplify the code a little when you want the value appropriately signed:
SELECT QUANTITY * IN_OUT AS REAL_QUANTITY FROM ...
Cheers,
John
This comment is totally OT to your original question relating to code erroneously producing nulls.
An alternative approach you may find interesting is to define IN_OUT as:
IN_OUT smallint default 1 check(value in (1,-1))
This can simplify the code a little when you want the value appropriately signed:
SELECT QUANTITY * IN_OUT AS REAL_QUANTITY FROM ...
Cheers,
John
> From: dinol.softedge <dinol@...> [snip]
> I have the following statement to determine whether stock is coming in
> or going out and assign the correct sign (+ or -) to a column called
> real_quantity. [snip]
> SELECT
> [snip]
> CASE
> WHEN IN_OUT = 'IN' THEN QUANTITY
> WHEN IN_OUT = 'OUT' THEN QUANTITY * -1
> END AS REAL_QUANTITY
> FROM
> TBL_INV_TRANS
> [snip]