Mrbaseball34
Programmer
I have this data in a fixed-length text file.
(there are 250,000 records)
1 2 3 4 5
1234567890123456789012345678901234567890123456789012345
2001010011001997002000330000000825000000132000000013200
2001010011001997003000330000000825000000132000000013200
2001010011001997 000330000000825000000132000000013200
2001010011001 000330000000825000000132000000013200
***********************************************************************
Here is the file schema:
Fieldname CharPos
------------- -------
ReinYear : 1-4
StateCode : 5-6
CropCode : 7-10
CountyCode : 11-13
TypeCode : 14-16
PracticeCode : 17-19
HighYield : 20-25
WarnYield : 26-35
MaxYield : 36-45
OverrideYield : 46-55
***********************************************************************
I need a DTS script to import these fields in this format:
HighYield 9999.9
WarnYield 99999999.99
MaxYield 99999999.99
OverrideYield 99999999.99
Example
( the first row above:
2001010011001997002000330000000825000000132000000013200
)
HighYield 33.0
WarnYield 82.50
MaxYield 132.00
OverrideYield 132.00
***********************************************************************
I've tried this but it gives me syntax errors:
(in the Replace, I presume)
Function Main()
DTSDestination("ReinYear"
= DTSSource("Col001"
DTSDestination("StateCode"
= DTSSource("Col002"
DTSDestination("CropCode"
= DTSSource("Col003"
if Len(Trim(DTSSource("Col004"
)) > 0 then
DTSDestination("CountyCode"
= DTSSource("Col004"
else
DTSDestination("CountyCode"
= NULL
end if
if Len(Trim(DTSSource("Col005"
)) > 0 then
DTSDestination("TypeCode"
= DTSSource("Col005"
else
DTSDestination("TypeCode"
= NULL
end if
if Len(Trim(DTSSource("Col006"
)) > 0 then
DTSDestination("PracticeCode"
= DTSSource("Col006"
else
DTSDestination("PracticeCode"
= NULL
end if
DTSDestination("HighYield"
= Replace(FormatNumber(DTSSource
("Col007"
,1), ',', '', 1, -1, 1)
DTSDestination("WarnYield"
= Replace(FormatNumber(DTSSource
("Col008"
,2), ',', '', 1, -1, 1)
DTSDestination("MaxYield"
= Replace(FormatNumber(DTSSource
("Col009"
,2), ',', '', 1, -1, 1)
DTSDestination("OverrideYield"
= Replace(FormatNumber(DTSSource
("Col010"
,2), ',', '', 1, -1, 1)
DTSDestination("OverrideFlag"
= DTSSource("Col011"
DTSDestination("UserId"
= DTSSource("Col012"
DTSDestination("Moddate"
= DTSSource("Col013"
Main = DTSTransformStat_OK
End Function
***********************************************************************
What am I doing wrong, here and how do I get my data imported correctly using DTS???
(there are 250,000 records)
1 2 3 4 5
1234567890123456789012345678901234567890123456789012345
2001010011001997002000330000000825000000132000000013200
2001010011001997003000330000000825000000132000000013200
2001010011001997 000330000000825000000132000000013200
2001010011001 000330000000825000000132000000013200
***********************************************************************
Here is the file schema:
Fieldname CharPos
------------- -------
ReinYear : 1-4
StateCode : 5-6
CropCode : 7-10
CountyCode : 11-13
TypeCode : 14-16
PracticeCode : 17-19
HighYield : 20-25
WarnYield : 26-35
MaxYield : 36-45
OverrideYield : 46-55
***********************************************************************
I need a DTS script to import these fields in this format:
HighYield 9999.9
WarnYield 99999999.99
MaxYield 99999999.99
OverrideYield 99999999.99
Example
( the first row above:
2001010011001997002000330000000825000000132000000013200
)
HighYield 33.0
WarnYield 82.50
MaxYield 132.00
OverrideYield 132.00
***********************************************************************
I've tried this but it gives me syntax errors:
(in the Replace, I presume)
Function Main()
DTSDestination("ReinYear"
DTSDestination("StateCode"
DTSDestination("CropCode"
if Len(Trim(DTSSource("Col004"
DTSDestination("CountyCode"
else
DTSDestination("CountyCode"
end if
if Len(Trim(DTSSource("Col005"
DTSDestination("TypeCode"
else
DTSDestination("TypeCode"
end if
if Len(Trim(DTSSource("Col006"
DTSDestination("PracticeCode"
else
DTSDestination("PracticeCode"
end if
DTSDestination("HighYield"
("Col007"
DTSDestination("WarnYield"
("Col008"
DTSDestination("MaxYield"
("Col009"
DTSDestination("OverrideYield"
("Col010"
DTSDestination("OverrideFlag"
DTSDestination("UserId"
DTSDestination("Moddate"
Main = DTSTransformStat_OK
End Function
***********************************************************************
What am I doing wrong, here and how do I get my data imported correctly using DTS???