MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

convert numeric code to alpha literal in QMF ?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Mon Nov 21, 2011 8:28 am    Post subject: convert numeric code to alpha literal in QMF ? Reply with quote

In QMF, is there a way to immediately convert a numeric value to an alpha value for display purposes ?

In other words, say I have a column called STATE_CODE that contains values 01 thru 49. When I perform the query, I want the report not to show 01 thru 50, but rather 'Arizona' thru 'Wyoming'.

Obviously, I would have to hard-code this, but would this be possible to do ?

Thanks for any help.
Back to top
View user's profile Send private message
GuyC
Supermod


Joined: 27 May 2011
Posts: 35
Topics: 0

PostPosted: Mon Nov 21, 2011 9:32 am    Post subject: Reply with quote

Do you mean without changing the query, directly in the report ?
I guess it's doable wih user defined edit codes : http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.qmf9.doc.iandm/edit.htm#edit

but the usual way is to join with a table in your query
Back to top
View user's profile Send private message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Mon Nov 21, 2011 7:40 pm    Post subject: Reply with quote

Looks like I have found one way to do it:

Code:
SELECT CASE(STATE_CODE)                     
       WHEN '01' THEN 'AL'             
       WHEN '02' THEN 'AZ'             
       WHEN '03' THEN 'AR'             
       WHEN '04' THEN 'CA'             
       WHEN '05' THEN 'CO'             
       END,                             
       POL_NUM||POL_SUFFIX AS POLICY#,
       POL_EFF_DATE   
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Nov 22, 2011 6:54 am    Post subject: Reply with quote

as long as i don't require a SELECT in my UDF
(because of the db2 vsn i am using)
i have several UDF's that 'convert' columns for spufi/unloads/qmf
since i am the creator, they are not used in imbedded sql.

i have several transaction type columns,
and there are some 140 different descriptions.
i have just pulled the 'descriptions' from application programs,
and wrote a UDF with a large (140 WHENs) CASE statement.
though possibly not as efficient as a join, much less code /
nur a function statement in the select.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Wed Nov 23, 2011 9:40 am    Post subject: Reply with quote

Create a table with the state_code and state_name and join this table with your table.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group