SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using the Script Component With Multiple Outputs


Using the Script Component With Multiple Outputs

Author
Message
parthi-1705
parthi-1705
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3224 Visits: 2196
Hi,

I just copy and past but getting error


public override void CreateNewOutputRows()
{
// Create the StreamReader object to read the input file
System.IO.StreamReader reader = new System.IO.StreamReader(this.Variables.Filename);

// Loop through the file to read each line
while(!reader.EndOfStream)
{
// Read one line
string line = reader.ReadLine();

// Break the file apart into atomic elements
string[] items = line.Split('|');

// Record type 1 is Manager
if (items[0] == "1")
{
ManagerOutputBuffer.AddRow();
ManagerOutputBuffer.ManagerID = int.Parse(items[1]);
ManagerOutputBuffer.ManagerName = items[2];
ManagerOutputBuffer.ManagerRole = items[3];
ManagerOutputBuffer.Location = items[4];
}

// Record type 2 is Employee
elseif (items[0] == "2")
{
EmployeeOutputBuffer.AddRow();
EmployeeOutputBuffer.EmployeeID = int.Parse(items[1]);
EmployeeOutputBuffer.ManagerID = int.Parse(items[2]);
EmployeeOutputBuffer.EmployeeName = items[3];
EmployeeOutputBuffer.EmployeeRole = items[4];
}

// Record type 3 is Client
elseif (items[0] == "3")
{
ClientOutputBuffer.AddRow();
ClientOutputBuffer.SalespersonID = int.Parse(items[1]);
ClientOutputBuffer.ClientID = int.Parse(items[2]);
ClientOutputBuffer.ClientName = items[3];
}
}
}

I am getting this error what that it means did i miss some thing refer screenshot

Thanks
Parthi

Thanks
Parthi
Attachments
error.JPG (10 views, 127.00 KB)
Tim Mitchell
Tim Mitchell
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6150 Visits: 3096
dpatel0501-696442 (5/21/2009)
So whats the right approach when we have records in the header as opposed to not having them in details?


If I read your question right, you're asking how to address the headers in a file? I haven't run across one of these multi-format files that had a header, because a single header can't describe the various metadata. Perhaps a file could have headers within the data - I haven't seen this approach, but if this exists you'd need to use your script to detect the header records (the method for which would vary depending on the makeup of the header) and either discard the headers or use them to identify the upcoming metadata.

hth,
Tim



Tim Mitchell, Microsoft Data Platform MVP
Data Warehouse and ETL Consultant
TimMitchell.net | @Tim_Mitchell | Tyleris.com
ETL Best Practices


Tim Mitchell
Tim Mitchell
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6150 Visits: 3096
psripuram (8/5/2010)
Can I have the same example shown in VB please


Unfortunately I don't have a VB example for this code - most of my sample scripts are in C#.



Tim Mitchell, Microsoft Data Platform MVP
Data Warehouse and ETL Consultant
TimMitchell.net | @Tim_Mitchell | Tyleris.com
ETL Best Practices


Tim Mitchell
Tim Mitchell
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6150 Visits: 3096
parthi-1705 (11/17/2010)
Hi, I just copy and past but getting error


It looks like there are a couple of errors. First of all, the
elseif

should be
else if

. It looks like the browser causes those to run together for some reason.

The highlighted error indicates that you don't have a variable named
Filename

in this scope. You'll want to create a variable with this name in your package, which should be populated with the name of the file you want to shred.

hth,
Tim



Tim Mitchell, Microsoft Data Platform MVP
Data Warehouse and ETL Consultant
TimMitchell.net | @Tim_Mitchell | Tyleris.com
ETL Best Practices


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search