April 16, 2009 at 6:32 am
I'm using the following code in the script component. The first two MsgBox's display during execution. The third MsgBox does not display. When the last record is processed and the MsgBox is displayed by the second MsgBox, Row.EndOfRowset is still False. According to everything I'vwe read it should be True. What have I not done? What do I need to do. I need to do some special processing after the last record have been processed.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Dim i As Integer
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
i = i + 1
If i < 3 Then
[b]MsgBox("Provider.id = " & Row.PROVIDERID & vbCrLf & _
"Record number = " & i & vbCrLf & _
"Seq No = " & Row.EXP837SEQNO)
End If[/b]
If i > 118 Then
MsgBox("Provider.id = " & Row.PROVIDERID & vbCrLf & _
"Record number = " & i & vbCrLf & _
"Seq No = " & Row.EXP837SEQNO)End If
Me.Output0Buffer.AddRow()
Me.Output0Buffer.newFile = Row.PROVIDERID & Row.EXP837SEQNO
If Row.EndOfRowset Then
MsgBox("end of rowset encountered")
End If
'
End Sub
Public Overrides Sub CreateNewOutputRows()
'
' Add rows by calling AddRow method on member variable called "Buffer"
' E.g., MyOutputBuffer.AddRow() if your output was named "My Output"
'
End Sub
April 16, 2009 at 7:39 am
william.hause (4/16/2009)
I'm using the following code in the script component. The first two MsgBox's display during execution. The third MsgBox does not display. When the last record is processed and the MsgBox is displayed by the second MsgBox, Row.EndOfRowset is still False. According to everything I'vwe read it should be True. What have I not done? What do I need to do. I need to do some special processing after the last record have been processed.Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Dim i As Integer
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
i = i + 1
If i 118 Then
MsgBox("Provider.id = " & Row.PROVIDERID & vbCrLf & _
"Record number = " & i & vbCrLf & _
"Seq No = " & Row.EXP837SEQNO)End If
Me.Output0Buffer.AddRow()
Me.Output0Buffer.newFile = Row.PROVIDERID & Row.EXP837SEQNO
If Row.EndOfRowset Then
MsgBox("end of rowset encountered")
End If
'
End Sub
Public Overrides Sub CreateNewOutputRows()
'
' Add rows by calling AddRow method on member variable called "Buffer"
' E.g., MyOutputBuffer.AddRow() if your output was named "My Output"
'
End Sub
Can you do your special processing in the PostExecute method?
April 16, 2009 at 7:52 am
I have added an override to FinishOutputs() and created my additional two two records to the end of the file. Thanks
Public Overrides Sub FinishOutputs()
MsgBox("Creating final records")
Me.Output0Buffer.AddRow()
Me.Output0Buffer.newFile = "GE*1*78890~"
Me.Output0Buffer.AddRow()
Me.Output0Buffer.newFile = "IEA*1*000078904~"
End Sub
April 16, 2009 at 1:12 pm
When I tried to use the PostExecute(), it did work. It only displayed info for Provider A, B & C. After processing the last Input record it did not execute the PostExecute () code and display Provider D.
Did I miss doing something?
Here is my data and the code
Data column 1 ProviderId, columns 2-3 Visits
A10
A07
A05
A19
B03
B16
B21
C05
D11
D12
D01
Code
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Dim i As Integer = 0
Dim Prov As String
Dim TotalVisits As Integer = 0
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
i += 1
If i = 1 Then
Prov = Row.ProviderId
End If
If Prov = Row.ProviderId Then
TotalVisits += Row.Visits
Else
MsgBox("Provider: " & Prov & vbCrLf & _
"Had " & TotalVisits & " visits")
TotalVisits = Row.Visits
Prov = Row.ProviderId
End If
End Sub
Public Overrides Sub PostExecute()
MsgBox("Provider: " & Prov & vbCrLf & _
"Had " & TotalVisits & " visits")
End Sub
End Class
April 16, 2009 at 3:23 pm
william.hause (4/16/2009)
When I tried to use the PostExecute(), it did work. It only displayed info for Provider A, B & C. After processing the last Input record it did not execute the PostExecute () code and display Provider D.Did I miss doing something?
Here is my data and the code
Data column 1 ProviderId, columns 2-3 Visits
A10
A07
A05
A19
B03
B16
B21
C05
D11
D12
D01
Code
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Dim i As Integer = 0
Dim Prov As String
Dim TotalVisits As Integer = 0
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
i += 1
If i = 1 Then
Prov = Row.ProviderId
End If
If Prov = Row.ProviderId Then
TotalVisits += Row.Visits
Else
MsgBox("Provider: " & Prov & vbCrLf & _
"Had " & TotalVisits & " visits")
TotalVisits = Row.Visits
Prov = Row.ProviderId
End If
End Sub
Public Overrides Sub PostExecute()
MsgBox("Provider: " & Prov & vbCrLf & _
"Had " & TotalVisits & " visits")
End Sub
End Class
Your question is confusing. Did or didn't work? Can you please re-phrase or provide more information. From the way your component works it looks like transformational component.
April 17, 2009 at 8:15 am
After a lot of research, I found the problem.
I left out the following line in the Public Overrides Sub PostExecture() Method
MyBase,PostExecute()
April 17, 2009 at 8:20 am
william.hause (4/17/2009)
After a lot of research, I found the problem.I left out the following line in the Public Overrides Sub PostExecture() Method
MyBase,PostExecute()
William,
The base method implementation is actually empty. So I don't think your problem was related to this line of code.
April 19, 2009 at 10:44 pm
I posted this reply to same question in the General discussion section (just now found this thread, so edited original to direct interested parties here).
--------------------------------------------
I'm not claiming expertise here, but maybe my questions can help.
Why do you expect Row.EndOfRowset to be true? If the looping is outside the script and the script only gets run for each row in the resultset, it wouldn't get executed once the Row.EndOfRowset condition is reached, right?
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply