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



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


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.