View previous topic :: View next topic
|
Author |
Message |
raje_17285
New User
Joined: 05 Mar 2008 Posts: 3 Location: chennai
|
|
|
|
I have a CHAR field in a DB2 TABLE. This field has both characters and comp-3 field in it. Need a query that can display comp-3 values in normal display format.
ex: field value: "asfsaf xxxxx sassfafs"
where xxxxx is comp-3 number field
i need this xxxxx to be displayed in normal format. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
raje_17285 wrote: |
I have a CHAR field in a DB2 TABLE. This field has both characters and comp-3 field in it. Need a query that can display comp-3 values in normal display format.
ex: field value: "asfsaf xxxxx sassfafs"
where xxxxx is comp-3 number field
i need this xxxxx to be displayed in normal format. |
If I took the time I might be able to figure out how to do it but it is such a stupid misuse of CHAR field that I am not going to even try. Trying reading in the sql manual about CAST. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Your post is confusing, meaning that you seeem to be confusing terms.
In your words, what makes xxxxx a comp-3 (a COBOL term) instead of just numeric (an English word)?
comp-3 is a COBOL term for a specific way (packed dec) to internally store numerics. The corresponding DB format is DEC, but that would be a column attribute, not just part of a char col.
I can store COBOL numerics, e.g., also as comp or display. Is there something in xxxxx that dictates comp-3? |
|
Back to top |
|
|
raje_17285
New User
Joined: 05 Mar 2008 Posts: 3 Location: chennai
|
|
|
|
Here goes the declaration of columns in two tables.
TABLE A
01 dclgen-tablea
05 filed1 PIC X(2).
05 filed2 PIC X(2).
05 filed3 PIC S9(13)V9(2) USAGE COMP-3.
05 filed4 PIC S9(13)V9(2) USAGE COMP-3.
TABLE B
01 dclgen-tableb
05 fieldx PIC X(20)
in program i move dclgen-tablea to fieldx and store the value in the TABLEB.
Noe i need to use this fieldx and get field3 and field4 values in display format.
Hope i am more clear now.
Thanks for your time. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
raje_17285 wrote: |
in program i move dclgen-tablea to fieldx and store the value in the TABLEB. |
Move dclgen-tablea to dclgen-tableb.
Quote: |
Noe i need to use this fieldx and get field3 and field4 values in display format. |
Move dclgen-tableb to dclgen-tablea.
Move field3 to field3-display.
Move field4 to field4-display.
I am confused why I'm even answering such a simplisticly dumb question..... |
|
Back to top |
|
|
raje_17285
New User
Joined: 05 Mar 2008 Posts: 3 Location: chennai
|
|
|
|
Thanks for the answer.....
I was not clear with my question.
Actually i need to get the
field3 and field4 from fieldx in the SQL QUERY itself.
ex:
select *
from
tableb
where
substr(fieldx,5,8) > 0
substr(fieldx,13,8) > 0
Here the substr(fieldx,5,8) is having the fielda (packed) in CHAR
Which can not be compared with numeric 0.
What i need is now to convert the substr(fieldx,5,8) to numeric and compare it with 0. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Did You have a doctor prescription for such a setup,
what is the business reason to have such an illogic thing,
if a field/column is a packed/binary number there is absolutely no reason
to have it embedded in an alphanumeric field/column |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Then try substr(fieldx,5,8) > X'000000000000000C' |
|
Back to top |
|
|
|