Mrbaseball34
Programmer
I'm trying to import the lines from a text file shown below
into a table using DTS with a transformation script.
(
fields in the file are not separated by '|', it is just
for illustration
)
Null replacement is working just fine, however the Yield
data keeps coming out as:
I am banging my head against the wall on this one, what
could be causing the incorrect values being inserted?
into a table using DTS with a transformation script.
(
fields in the file are not separated by '|', it is just
for illustration
)
Code:
1 2 3 4 5 6 7
1234|56|7890|123|456|789|012345|6789012345|6789012345|6789012345|67|89012345|67890123
2002|01|0021|001|997| |006720|0000154560|0000268800|0000268800| | |20020601
2002|01|0021|001| | |006720|0000154560|0000268800|0000268800| | |20020601
{Source may wrap}
Here is the script:
Function Main()
Dim strVar
Dim strDec
DTSDestination("ReinYear") = DTSSource("Col001")
DTSDestination("StateCode") = DTSSource("Col002")
DTSDestination("CropCode") = DTSSource("Col003")
if ((Len(Trim(DTSSource("Col004"))) > 0) and (Trim(DTSSource("Col004")) <> "000")) then
DTSDestination("CountyCode") = DTSSource("Col004")
else
DTSDestination("CountyCode") = NULL
end if
if (Len(Trim(DTSSource("Col005"))) > 0) and (Trim(DTSSource("Col005")) <> "000")then
DTSDestination("TypeCode") = DTSSource("Col005")
else
DTSDestination("TypeCode") = NULL
end if
if (Len(Trim(DTSSource("Col006"))) > 0) and (Trim(DTSSource("Col006")) <> "000")then
DTSDestination("PracticeCode") = DTSSource("Col006")
else
DTSDestination("PracticeCode") = NULL
end if
strVar = Left(DTSSource("Col007"), 5)
strDec = Right(DTSSource("Col007"), 1)
DTSDestination("HighYield") = CStr(Replace(FormatNumber(strVar & "." & strDec, 1), ",", "", 1, -1, 1))
strVar = Left(DTSSource("Col008"), 8)
if (CLng(strVar) = 99999999) then
DTSDestination("WarnYield") = NULL
else
strDec = Right(DTSSource("Col008"), 2)
DTSDestination("WarnYield") = CStr(Replace(FormatNumber(strVar & "." & strDec, 2), ",", "", 1, -1, 1))
end if
strVar = Left(DTSSource("Col009"), 8)
strDec = Right(DTSSource("Col009"), 2)
DTSDestination("MaxYield") = CStr(Replace(FormatNumber(strVar & "." & strDec, 2), ",", "", 1, -1, 1))
strVar = Left(DTSSource("Col010"), 8)
strDec = Right(DTSSource("Col010"), 2)
DTSDestination("OverrideYield") = CStr(Replace(FormatNumber(strVar & "." & strDec, 2), ",", "", 1, -1, 1))
DTSDestination("OverrideFlag") = DTSSource("Col011")
DTSDestination("UserId") = DTSSource("Col012")
DTSDestination("Moddate") = DTSSource("Col013")
Main = DTSTransformStat_OK
End Function
Null replacement is working just fine, however the Yield
data keeps coming out as:
Code:
HighYield : 672.0 (correct)
WarnYield : 1545.00 (incorrect, should be 1545.60)
MaxYield : 26880.00 (incorrect, should be 2688.00)
OverrideYield : 2688.00 (correct)
could be causing the incorrect values being inserted?