Varchar to Decimal issue
Moderators: chulett, rschirm, roy
Varchar to Decimal issue
I have a file with a varchar numeric field containing a maximum of 6 caracters (for example 3.45 or 23.45 or 234.56). I need to load this field in a DB2 table where the field is defined (decimal 5,2).
I have tried many possibilities using stringtodecimal function with no success mainly due to the decimal point in the source field I believe.
What is the easiest way to succeed ?
Thanks in advance for your help.
I have tried many possibilities using stringtodecimal function with no success mainly due to the decimal point in the source field I believe.
What is the easiest way to succeed ?
Thanks in advance for your help.
Cyrille Hallard
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Blunt object through window approach: Stage variable svADHchar Char(6) -- StringToString (ADHPCT) (set PADCHAR to 0x20); svAdhpct -- StringToDecimal (Trim(svADHchar)).
Have I mentioned yet today that putting numeric values in VarChar fields is a royal pain in the arse?
Have I mentioned yet today that putting numeric values in VarChar fields is a royal pain in the arse?
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Just remembered that you indicated the output value as 0.00. Sometimes this is from a type conversion failure that you might miss because it's a warning level log entry.
Try increasing the size of the decimal ADHPCT to 6,2 or more. Stage variables are usually defaulted to signed, and that might be why the conversion is defaulting to zero.
Also, insert a peak. What you see on DB2 may not be what you see in the buffer.
Try increasing the size of the decimal ADHPCT to 6,2 or more. Stage variables are usually defaulted to signed, and that might be why the conversion is defaulting to zero.
Also, insert a peak. What you see on DB2 may not be what you see in the buffer.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson
Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872