View previous topic :: View next topic
|
Author |
Message |
souji
New User
Joined: 28 Aug 2008 Posts: 9 Location: Bangalore
|
|
|
|
Hi,
I have encountered the following situation and need your help regarding the following.
I have a varchar variable which at some position is holding '.....&..' If I retrieve this value in a char variable I get '.....&..'. But actually this is the hexadecimal for 500.11. My requirement is to pull this as a decimal. A decimal variable declared as fixed decimal(15,2) should hold 500.11.
can this be done though the built in functions or/and the implicit assignments.
Please help ! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Soujanya and welcome to the forum,
First - are you working with pl/i or assembler (or)?
Next - please post the "hex" content for the '.....&..' value.
Quote: |
A decimal variable declared as fixed decimal(15,2) should hold 500.11. |
A field of 15,2 should hold a value much greater than 500.11. . .
If you post the bit of problem code (not the entire program) someone shouold be able to offer a suggestion. |
|
Back to top |
|
|
souji
New User
Joined: 28 Aug 2008 Posts: 9 Location: Bangalore
|
|
|
|
Hi Dick...
I am working on PL/I..
the hex content for the value is
.....&..
00000501
0000001C
Thanks & Regards,
Soujanya[/img] |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The value you posted is a valid packed decimal number with a value of 50011. The "C" indicates the number is positive.
Are you familiar with the packed-decimal data format? |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Souji,
You can redefine the same char field with a dec(15,2). |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
You can redefine the same char field with a dec(15,2).
|
In the case described by the O/P, the varchar has length 8. A dec fixed(15,n) field could be overlaid on this. However, if the varchar is a different length, DEC FIXED(15,n) will be incorrect. Multiple overlays of dec fixed fields could be used, selecting which overlay to use on the basis of the length of the varchar?
Garry. |
|
Back to top |
|
|
|