View previous topic :: View next topic
|
Author |
Message |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Hopefully, this signed, zoned-decimal number will not be used as a key. . . |
|
Back to top |
|
|
balbudheprashant Warnings : 2 New User
Joined: 24 Aug 2007 Posts: 5 Location: Pune
|
|
|
|
[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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Prashant ,
What is this? I don't understand. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|