IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To display comp-3 variable


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raje_17285

New User


Joined: 05 Mar 2008
Posts: 3
Location: chennai

PostPosted: Wed Mar 05, 2008 4:23 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Mar 05, 2008 6:20 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Mar 05, 2008 7:16 pm
Reply with quote

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
View user's profile Send private message
raje_17285

New User


Joined: 05 Mar 2008
Posts: 3
Location: chennai

PostPosted: Thu Mar 06, 2008 9:54 am
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 06, 2008 3:14 pm
Reply with quote

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
View user's profile Send private message
raje_17285

New User


Joined: 05 Mar 2008
Posts: 3
Location: chennai

PostPosted: Thu Mar 06, 2008 4:04 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 06, 2008 4:10 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 06, 2008 6:41 pm
Reply with quote

Then try substr(fieldx,5,8) > X'000000000000000C'
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top