× 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.



Vern,
The condition that I am attempting to resolve is that when a field from
another file (DSPF) contains a specific value, I want to create another
field in my result set.
ex. Case SHOW_QTY When 1 then OnHand - Committed Else OnHand End.
SHOW_QTY is a field in my DSPF.
OnHand and Committed are fields in one of the files in my select from.

Jeff Young
Sr. Programmer Analyst

On Tue, Feb 24, 2015 at 3:16 PM, Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx>
wrote:

I'm going to say no - what is being tested, then, is a numeric or alpha
constant, not an expression in the usual sense.

So let's say my_field = 15 - your CASE becomes

CASE 15 WHEN .... END

Even if this WOULD run, the only time it is true is when one of your test
values is 15.

It does appear that it COULD run - I just tried this in STRSQL -


select case 15 when 12 then 12 when 15 then 2 else 0 end from
sysibm/sysdummy1

It displays the number 2.

You probably want something like

CASE SOMEFIELD WHEN :my_field THEN some_value ELSE DEFAULT_VALUE END

HTH
Vern


On 2/24/2015 1:57 PM, Jeff Young wrote:

All,
Is there a way to use a host variable in a CASE statement as the field to
be tested?
ie: CASE :my_field WHEN .... END

Would that work?

Jeff Young
Sr. Programmer Analyst


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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.