Microsoft
Software
Hardware
Network
Question : DTS Transform Skip Row, loads no data
I have a fixed width file format which I need to load into SQL table (formatting it first). The final row of the file is a footer record containgin only the number of records contained therein for audit purposes. Here's an example file format:
10022237000005944+E15/09/2
005
10047126000091362+E15/09/2
005
10050400000001633-E15/09/2
005
10108870000024422-E15/09/2
005
10428947000003309+E15/09/2
005
10433786000036697+E15/09/2
005
10527663000023497+C15/09/2
005
10553812000001158-E15/09/2
005
10602188000003157+C15/09/2
005
10634579000004887+C15/09/2
005
T0000010
In the first steps of the package I do all sorts of initalising and parse the expected number of records from the footer. I then have a DTS Transform from the file to the SQL Destination as below.
'*************************
**********
**********
**********
**********
*****
' Visual Basic Transformation Script
'*************************
**********
**********
**********
**********
*******
Option Explicit
Const EP_LENGTH_YEAR = 4
Const EP_START_MONTH = 3
Const EP_LENGTH_MONTH = 2
Const EP_LENGTH_DAY = 2
Const EP_LENGTH_TRAILERID = 1
Function Main()
Dim xml
Dim serviceAccount
Dim debtAmount
Dim billType
Dim billDate
Dim billYear
Dim billMonth
Dim billDay
Dim trailerId
'Just Exist
If DTSGlobalVariables("gvReco
rdsLoaded"
).Value = DTSGlobalVariables("gvReco
rdsExpecte
d").Value - 1 Then
Msgbox "Found footer - skipping row"
Main = DTSTransformStat_SkipRow
End If
'Parse the attributes into variables
serviceAccount = DTSSource("Col001")
debtAmount = DTSSource("Col003") & CLng( DTSSource("Col002") )
billType = DTSSource("Col004")
billDate = DTSSource("Col005")
billYear = Right(billDate , EP_LENGTH_YEAR)
billMonth = Mid(billDate, EP_START_MONTH, EP_LENGTH_MONTH)
billDay = Left(billDate, EP_LENGTH_DAY)
'Parse the attributes into an XML string
xml = ""
xml = xml & "
xml = xml & " ServiceAccount=" & """" & serviceAccount & """"
xml = xml & " Amount=" & """" & debtAmount & """"
xml = xml & " Type=" & """" & billType & """"
xml = xml & " Date=" & """" & billYear & "-" & billMonth & "-" & billDay & "T00:00:00" & """"
xml = xml & "/>"
'Insert the source into the destination column
DTSDestination("ep_task_id
") = 0
DTSDestination("ep_task_xm
l") = xml
' Thes reference values are required for the job
DTSDestination("ep_task_fi
le_id") = DTSGlobalVariables("gvFile
Id").Value
DTSDestination("ep_task_ta
st_id") = 23
DTSDestination("ep_task_rq
st_id") = 100
DTSDestination("ep_task_st
atus") = "Q"
' Increment the load counter
DTSGlobalVariables("gvReco
rdsLoaded"
).Value = DTSGlobalVariables("gvReco
rdsLoaded"
).Value + 1
Main = DTSTransformStat_OK
End Function
The intended purpose of this transformation is to load all rows which are not the footer records. The script will debug and show me that the footer has been found and skip that row, however NO records are created in my destination table and no further errors are created.
This is an extremely urgent requirement and carries some hefty points.
Answer : DTS Transform Skip Row, loads no data
>>The script will debug and show me that the footer has been found and skip that row, however NO records are created in my destination table and no further errors are created.<<
I would have expected exactly the opposite: All rows are added, including the footer. Reason for that is that you are setting:
Main = DTSTransformStat_SkipRow
But then you re-set it at the end of the function to:
Main = DTSTransformStat_OK
Which negates the first assignment. I suggest that when you figure out your problem, add "Exit Function" after "Main = DTSTransformStat_SkipRow" or use some other logic.
Also, rather than this:
If DTSGlobalVariables("gvReco
rdsLoaded"
).Value = DTSGlobalVariables("gvReco
rdsExpecte
d").Value - 1 Then
I would do this:
If Left(DTSSource("Col001"), 1) = "T" Then
Finally, lose the MsgBox it will probably cause you grief in a scheduled (unattended) job.
Random Solutions
Must Have Terminal Server User Access Permissions--Error
Display Properties, Appearance, Windows and Buttons has lost "Windows XP Style". Only option is "Windows Classic Style".
"Fuzzy" image on LCD screen
Filetype/Action definition for .XLS filetype
Automate the enabling of Microsoft Terminal Services Client Control ActiveX control, mstscax.dll, for TS2008 remote app
Highlight Command Button to Show Active
Boot disk w/ cd rom drivers
loadSound vs. attachSound - latency latency latency...
URGENT - - Need to Copy files from AIX server to Windows XP workstation
DECODE in Sybase