Issue :SSIS Package data tranformation in loop script component
I have developed package in sql server 2008 r2. I want to convert the data
using script block.but i got the error that was the first and last records
is not inserted and it tries to insert null that violates integrity
contraint..below is my code in vb script..
<microsoft.sqlserver.dts.pipeline.ssisscriptcomponententrypointattribute()>
_ <clscompliant(false)> _ Public Class ScriptMain Inherits UserComponent
Dim i As Integer = 0
Public Overrides Sub PreExecute()
MyBase.PreExecute()
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
End Sub
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
i = i + 1
With Output0Buffer
.OrderHeaderID = i
.CustomerNumber = Row.CUSTNO
.OrderNumber = Row.ORDER
.TermsCode = Row.TRMSCD
.TermsDescription = Row.TRMDSC
.TotalLines = Row.TOTLNS
.TotalDollars = Row.TOTDOL
.ComCls = Row.COMCLS
.DropShip = Row.DRPSHP
.DropshipPurchaseOrder = Row.DSPONO
.InvoiceNumber = Row.INVNO
.LstSeq = Row.LSTSEQ
.OrderType = Row.ORDTYP
.PONumber = Row.PONUMB
.ProgramCode = Row.PROGCD
.ProgramDeal = Row.PROGDL
.ProgramName = Row.PRGNAM
.PRONumber = Row.PRONUM
.ReceivedVia = Row.RCVVIA
.StatusMessage = Row.STAMSG
.TermsDescription = Row.TRMDES
.TermsDiscount = Row.TRMDSC
.TruckName = Row.TRKNAM
If IsDate(Row.SHPDAT) Then
.ShipDate = Row.SHPDAT
End If
If IsDate(Row.ORDDAT) Then
.OrderDate = Row.ORDDAT
End If
If IsDate(Row.INVDAT) Then
.InvoiceDate = Row.INVDAT
End If
If IsDate(Row.DATING) Then
.Dating = Row.DATING
End If
If Not Row.INVDAT_IsNull Then
.AddRow()
Else
Exit Sub
End If
End With
End Sub
Public Overrides Sub CreateNewOutputRows()
Output0Buffer.AddRow()
End Sub
End Class
Currently i am trying to insert 10 rows but it gives error. Please guide me.
Thanks in advance. Ritesh
No comments:
Post a Comment