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

Moving from X(2) to Decimal(2,1)


IBM Mainframe Forums -> DB2
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Tue Nov 18, 2008 10:35 pm
Reply with quote

I have a cobol varible of Pic Clause X(2) containing values 11, 20,33, Now I want to upload from this varible to DB2 table field of Decimal(2,1). if I will upload the DB2 table directly from X(2) cobol varible, will it store in table 1.1, 2.0,3.3. If not then how it is possible?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Nov 18, 2008 10:46 pm
Reply with quote

debasis misra,

I dont think you'll be able to load as such from an X(2) variable. One way is to manipulate the data to get it in the desired format and then load the table. BTW,Which utility are you using to load the table?
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Wed Nov 19, 2008 8:59 am
Reply with quote

we are loading table through the cobol program only.
what is the "desired format" ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Nov 19, 2008 9:33 am
Reply with quote

Hello,

In the cobol program, redefine the pic x(2) as a pic 9v9. Use the 9v9 to update the table (after varifying that the value in the field is valid).
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Nov 19, 2008 12:08 pm
Reply with quote

Quote:
what is the "desired format" ?

Hello,

You'll have to have the final host variable as COMP-3 type which corresponds to the DB2 DECIMAL.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Nov 19, 2008 8:49 pm
Reply with quote

Hello,

Thanks Arun icon_smile.gif

To be more complete. . . .

After redefining the pic x(2) variable to pic 9v9, move the 9v9 redefined variable to a pic 9v9 comp-3 variable which would be named as the host variable for the database update.

Again, you need to make sure the initial input value is valid as anything might be in a pic x field.
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Thu Nov 20, 2008 8:48 am
Reply with quote

Thanks for all suggestion. Its my understanding:

A ---- X(2) --- I/P
B ---- 9V9 Comp-3 --- Host variable.

C --- decimal (2,1) --- DB2 table varible.
===
Move A to B.
Then insert to C from B.

Now If A = 11
Then C = 1.1
===
Please suggest wheather its correct or not?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Nov 20, 2008 9:01 am
Reply with quote

Hello,

Personally, i'd suggest:
A ---- X(2) --- I/P
A-REDEF REDEFINES 9v9 (redefinition of i/p)

B ---- 9V9 Comp-3 --- Host variable.

Move A-REDEF to B.
Then insert to C from B.

Then:
If A = 11
Then C = 1.1

Before the move, i'd suggest validating that the i/p is valid - otherwize you may have an oc7 or sql error.
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Mon Nov 24, 2008 9:11 pm
Reply with quote

IF we know how the DCL variable is declared for the field in a particular table, we can redefine the working storage variable in such a way right!!! tell me if i am wrong.
Back to top
View user's profile Send private message
akashsr_09

New User


Joined: 10 Apr 2021
Posts: 3
Location: India

PostPosted: Wed Aug 11, 2021 6:56 pm
Reply with quote

can't we directly move to 9v9 Comp-3 variable ?
why should we first redefine as 9v9 ?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Wed Aug 11, 2021 7:06 pm
Reply with quote

akashsr_09 wrote:
can't we directly move to 9v9 Comp-3 variable ?
why should we first redefine as 9v9 ?

Please, start from reading any COBOL manual.
Otherwise there is no chance to understand the responses.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Aug 11, 2021 9:33 pm
Reply with quote

another winner here,
resurrecting a 13 years old topic 36_8_11.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Aug 12, 2021 4:24 am
Reply with quote

akashsr_09 wrote:
can't we directly move to 9v9 Comp-3 variable ?
why should we first redefine as 9v9 ?

Please don’t tailgate old posts.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts String has hex character need to conv... COBOL Programming 3
Search our Forums:

Back to Top