Re: Re: CASE statement frustration...
Posted in 2004
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design, Versions, Editions & End-of-Life
As someone said earlier CASE works in SPL but in XPS not in IDS, the manual confirms it.
When I read this e-mail I was happy that I were wrong... Now I'm unhappy that I'm rigth...
I always hated why the syntax of XPS its different (better i Think) from IDS...
Chucho!
-----Original Message-----
From: "Doug Lawry" <lawry@nildram.co.uk>
To: informix-list@iiug.org
Date: Wed, 23 Jun 2004 10:17:38 +0100
Subject: Re: CASE statement frustration...
Sorry guys, but you've missed the point :o) (Jean was close.)
SQL CASE is an excellent feature, fully supported in SPL, and
very different to 4GL CASE. The statement should be changed to:
LET v_res =
CASE v_test
WHEN 0 THEN '1'
WHEN 1 THEN '2'
WHEN 2 THEN '3'
ELSE 'else'
END;
I hate to say that it's identical in SQL Server ...
Regards,
Doug Lawry
www.douglawry.webhop.org
"Sean Kelsey" <sean.kelsey@moneyline.com> wrote:
> IDS 9.40.TC4 (on Windows 2000 Advanced Server)
>
> Afternoon all...
>
> Can anyone tell me why the folloiwng CASE statement embedded within a
> SPL won't work? Its really bugging me.
>
> TIA.
>
> Sean.
>
> CREATE PROCEDURE MIS_DoTest()>
> DEFINE v_test INTEGER;
> DEFINE v_res VARCHAR(12);
>
> LET v_test = 1;
> LET v_res = '0';
>
> CASE v_test
> WHEN 0 THEN
> LET v_res = '1';
> WHEN 1 THEN
> LET v_res = '2';
> WHEN 2 THEN
> LET v_res = '3';
> ELSE
> LET v_res = 'else';
> END CASE;
>
> END PROCEDURE;
Jean Sagi
jeansagi@myrealbox.com
jeansagi@netscape.net
sending to informix-list
Hi Jean.
What version of IDS do you have? It works for me in SPL on:
HP 9.20.FC2
HP 9.30.HC1
XP 9.40.TC2
Doug
Jean Sagi said:
> As someone said earlier CASE works in SPL but in XPS not in IDS, the manual
> confirms it.
>
> When I read this e-mail I was happy that I were wrong... Now I'm unhappy that
> I'm rigth...
>
> I always hated why the syntax of XPS its different (better i Think) from
> IDS...
>
> Chucho!
>
>
> -----Original Message-----
> From: "Doug Lawry" <lawry@nildram.co.uk>
> To: informix-list@iiug.org
> Date: Wed, 23 Jun 2004 10:17:38 +0100
> Subject: Re: CASE statement frustration...
>
> Sorry guys, but you've missed the point :o) (Jean was close.)
>
> SQL CASE is an excellent feature, fully supported in SPL, and
> very different to 4GL CASE. The statement should be changed to:
>
> LET v_res CASE v_test
> WHEN 0 THEN '1'
> WHEN 1 THEN '2'
> WHEN 2 THEN '3'
> ELSE 'else'
> END;
>
> I hate to say that it's identical in SQL Server ...
>
> Regards,
> Doug Lawry
> www.douglawry.webhop.org
>
>
> "Sean Kelsey" <sean.kelsey@moneyline.com> wrote:
>
>> IDS 9.40.TC4 (on Windows 2000 Advanced Server)
>>
>> Afternoon all...
>>
>> Can anyone tell me why the folloiwng CASE statement embedded within a
>> SPL won't work? Its really bugging me.
>>
>> TIA.
>>
>> Sean.
>>
>> CREATE PROCEDURE MIS_DoTest()>>
>> DEFINE v_test INTEGER;
>> DEFINE v_res VARCHAR(12);
>>
>> LET v_test = 1;
>> LET v_res = '0';
>>
>> CASE v_test
>> WHEN 0 THEN
>> LET v_res = '1';
>> WHEN 1 THEN
>> LET v_res = '2';
>> WHEN 2 THEN
>> LET v_res = '3';
>> ELSE
>> LET v_res = 'else';
>> END CASE;
>>
>> END PROCEDURE;