× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

as Vern pointed out both forms are valid, but the second one is much more
powerful.

CASE Fld When Value1 Then Return1
When Value2 Then Return2
Else Return3 End

If the example above only the contents of a field are compared with equal.
In the other version, you are not restricted to a single field nor to the
equal operator

Example:
Case When Fld1 < 100 and Fld2 = 'A' then Value1
When Fld2 between 100 and 500 and Fld2 in ('X', 'Y') and Fld3 is NULL
Then Value2
When Fld3 is Not NULL Then Value3,
When Fld4 + 3 Days > Current_Date Then Value4
Else Value4 End


Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Vern Hamberg
Gesendet: Wednesday, 13. January 2010 04:27
An: RPG programming on the IBM i / System i
Betreff: Re: Can anyone explain this?

Hi Dennis

Both forms are valid on the i and might be on most compliant SQL systems
- I don't know that, however. I do prefer the form you used, by the way
- but it seems both forms have analogs in various languages.

Vern

Dennis Lovelady wrote:
Portion of SQL statement:
CASE C.ASTOCK WHEN 'N' THEN 'No' WHEN 'Y' THEN 'Yes' END,
CASE C.AFUEL WHEN 'N' THEN 'No' WHEN 'Y' THEN 'Yes' END,


That syntax is foreign to me. I like it (a lot) and it may be valid, but
what I'm used to is:
CASE
WHEN C.ASTOCK = 'N' then 'No'
WHEN C.ASTOCK = 'Y' then 'Yes'
ELSE C.ASTOCK end,

What OS are you using?

Only thing I can think of other than syntax is unprintables after the N or
Y, maybe?

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"If I'd known I was going to live so long, I'd have taken better care of
myself."
-- Leon Eldred





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.