I receive a text file from another site which contains negative values.
The problem is that the negative sign is in a fixed position in the file not floating. Also within a single record the field values can be either positive of negative.
I currently have a CTL that would load the file correctly if all the fields in the record are negative (see below) but without having the file changed by the other site (which is not an option at this time)how can I get these negative values loaded into a table?
One option that has been thought of is to load the negative value in a separate column in the table then manipulate the fields accordingly or use an external table. If the external table is the best option I have no knowledge of this, could you fill me in or give me a reference (web site or other)to do some research ? Thanks in advance ...
INPUT DATA EXAMPLE(3 records):
010464 A000052 - 00027.00 00150.00 00000.00 -00027.00
011521 B000112 - 00100.94 00200.00 00000.00 - 00100.94
022135 L000064 - 00004.33 00345.00 00000.00 - 00004.33
CTL Example(which currently loads the last field. This could load the first three fields if all fields in the record were negative but that can not be assumed)
LOAD DATA
INFILE '\\tsos\test\data\afms_current.dat'
TRUNCATE
INTO TABLE AFMS_CURRENT_TABLE
WHEN (58) != '-'
(CON POSITION(001:006)CHAR,
JON POSITION(012:018) CHAR,
TOT_SURCHARGE POSITION(060:067) DECIMAL EXTERNAL
)
INTO TABLE AFMS_CURRENT_TABLE
WHEN (58) = '-'
(CON POSITION(001:006) CHAR,
JON POSITION(012:018) CHAR,
TOT_SURCHARGE POSITION(060:067) DECIMAL EXTERNAL
"TOT_SURCHARGE/-1"
)
The problem is that the negative sign is in a fixed position in the file not floating. Also within a single record the field values can be either positive of negative.
I currently have a CTL that would load the file correctly if all the fields in the record are negative (see below) but without having the file changed by the other site (which is not an option at this time)how can I get these negative values loaded into a table?
One option that has been thought of is to load the negative value in a separate column in the table then manipulate the fields accordingly or use an external table. If the external table is the best option I have no knowledge of this, could you fill me in or give me a reference (web site or other)to do some research ? Thanks in advance ...
INPUT DATA EXAMPLE(3 records):
010464 A000052 - 00027.00 00150.00 00000.00 -00027.00
011521 B000112 - 00100.94 00200.00 00000.00 - 00100.94
022135 L000064 - 00004.33 00345.00 00000.00 - 00004.33
CTL Example(which currently loads the last field. This could load the first three fields if all fields in the record were negative but that can not be assumed)
LOAD DATA
INFILE '\\tsos\test\data\afms_current.dat'
TRUNCATE
INTO TABLE AFMS_CURRENT_TABLE
WHEN (58) != '-'
(CON POSITION(001:006)CHAR,
JON POSITION(012:018) CHAR,
TOT_SURCHARGE POSITION(060:067) DECIMAL EXTERNAL
)
INTO TABLE AFMS_CURRENT_TABLE
WHEN (58) = '-'
(CON POSITION(001:006) CHAR,
JON POSITION(012:018) CHAR,
TOT_SURCHARGE POSITION(060:067) DECIMAL EXTERNAL
"TOT_SURCHARGE/-1"
)