Subject Re: [firebird-support] Using CIF UDF
Author Helen Borrie
At 03:32 PM 13/07/2004 -0700, you wrote:
>Hello,
>
>I am using a UDF with the following definition:
>
>DECLARE EXTERNAL FUNCTION CIF
> INTEGER, CSTRING(255), CSTRING(255)
> RETURNS CSTRING(255)
> ENTRY_POINT 'fn_cif' MODULE_NAME 'rfunc';
>
>Here is what I am trying to do:
>
>select CIF((APPLICATIONS.CID = 'N/A'), '', APPLICATIONS.ENG_TYPE || ' CID')
>as CI
> >From APPLICATIONS
>
>What I want is if APPLICATIONS.CID contains 'N/A', I want it to return an
>empty string otherwise the concatonated value of APPLICATIONS.CID and '
>CID'.
>
>Can someone show me the light?

If you're using Fb 1.5 you can use a CASE expression:

select
....,
CASE CIF(CID) = 'N/A' then ''
ELSE ENG_TYPE || ' ' || CIF(CID) END AS WHATEVER,
....
from APPLICATIONS

/hb