View previous topic :: View next topic |
Author |
Message |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Mon Nov 21, 2011 8:28 am Post subject: convert numeric code to alpha literal in QMF ? |
|
|
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 |
|
 |
GuyC Supermod
Joined: 27 May 2011 Posts: 35 Topics: 0
|
|
Back to top |
|
 |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Mon Nov 21, 2011 7:40 pm Post subject: |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Nov 22, 2011 6:54 am Post subject: |
|
|
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 |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Wed Nov 23, 2011 9:40 am Post subject: |
|
|
Create a table with the state_code and state_name and join this table with your table. |
|
Back to top |
|
 |
|
|