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

Moving Signed value to Alpbha-numeric field.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Mon Nov 19, 2007 4:18 pm
Reply with quote

Hi all,

I have a field like below.

WS-ITR PIC S9(04).

But in DB2 table, the corresponding column data type is VARCHAR(04).

So I have to move it to Alpha-numeric field say X(04). And X(04) is enough or not?

Or X(05) is needed to retain sign?

Consider the value for WS-ITR is -2009. So, in this case, is it possible to have sign stored in database?

Note : I think S9(04) will take only 4 bytes in memory. Correct me if I am wrong.

Thanks,
Gnanas
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Mon Nov 19, 2007 6:25 pm
Reply with quote

gnanas wrote:
Hi all,

I have a field like below.

WS-ITR PIC S9(04).

But in DB2 table, the corresponding column data type is VARCHAR(04).

So I have to move it to Alpha-numeric field say X(04). And X(04) is enough or not?

Or X(05) is needed to retain sign?

Consider the value for WS-ITR is -2009. So, in this case, is it possible to have sign stored in database?

Note : I think S9(04) will take only 4 bytes in memory. Correct me if I am wrong.

Thanks,
Gnanas


You have a serious design problem that needs fixed. You could refine the s9(4) field as x(4) then store the x(4) field in the database but many times it would apear to be garbage and would not be searchable. Why would you want to do this?
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Mon Nov 19, 2007 7:04 pm
Reply with quote

Craq Giegerich says

Quote:
... store the x(4) field in the database but many times it would apear to be garbage and would not be searchable.



Could you please explain in detail? I couldn't get the point.

Thanks,
Gnanas
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Nov 19, 2007 7:30 pm
Reply with quote

pic s9(4) will indeed only use 4 bytes since the sign is an overprint. that is what craig meant by garbage. (e.g. -234 WB 023M) now, how could you find that?

but as craig said, if you have numeric data, store it as numeric data; to do otherwise is just rookie behavior.
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: Mon Nov 19, 2007 10:54 pm
Reply with quote

Hello,

Hopefully, this signed, zoned-decimal number will not be used as a key. . .
Back to top
View user's profile Send private message
balbudheprashant
Warnings : 2

New User


Joined: 24 Aug 2007
Posts: 5
Location: Pune

PostPosted: Tue Nov 20, 2007 2:56 pm
Reply with quote

[quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code][list][list=][img][/img][url][b][i][u][quote][code]
    [list=][img][/img][url][b][i][u]
    Quote:
    [code]
      [list=][img][/img][url][/url]
    [/code]
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Nov 20, 2007 3:07 pm
Reply with quote

Prashant ,

What is this? I don't understand.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 20, 2007 3:52 pm
Reply with quote

Why in the world are you using a varchar for 4 bytes? considering that you will always have a length for two bytes you are creating a 6 byte column, of which 4 bytes are available for data and you are trying to stuff 5 descret characters into it.

although s9(4) only takes up 4 bytes, you need five bytes to make any sense out of it (to show the sign).

suggest the varchar(04) column be dropped and a either a char(5) or smallint column be added.

if you just have to go with the char col, suggest you move the host variable s9(4) to an edit mask, then update the column with the edit mask.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top