You cannot fill the Output0Buffer
outside the Input0_ProcessInputRow(Input0Buffer Row)
function
But if you want to get the data from SQL queries and feed that to the output, you need to load the SQL output into a DataTable object, work further on that, and then you can get the DataTable's row data for each row that you loop through with the Input0_ProcessInputRow(Input0Buffer Row)
function by means of the row indices of the DataTable object. By this, you can do the work that you want to do in the PostExecute()
function already before the Input0_ProcessInputRow(Input0Buffer Row)
function so that the Script Component output will show the full work.
This does not answer your question of how you can put more rows in the output, but it shows that you can change the output rows as much as you want, and if that can be done, you might also make a Multicast, run the one Script Component as you have it but to its side, run another Script Component with the same row input and change that to your needs so that it outputs all of the rows that you need on top. After this, union the two Output0Buffers to one output by means of the Union tool.
PostExecute() cannot fill the "Output0Buffer" output of the Script Component
Here is how the code would look like in the PostExecute()
function, but mind that this is just to show that it does not work. From the default file:
This method is called after all the rows have passed through this component.
The input comes from the SQL query, and the while (reader.Read())
is a loop over the rows, but what I try here cannot work since the Output0Buffer
only works in the Input0_ProcessInputRow(Input0Buffer Row)
:
Thus, this does not work:
public override void PostExecute()
{
base.PostExecute();
// Output data from the temporary table
string selectQuery = @"SELECT *
FROM xyz;";
cmd = new SqlCommand(selectQuery, conn);
var reader = cmd.ExecuteReader();
while (reader.Read())
{
Output0Buffer.AddRow();
// Check if the value is null
if (!reader.IsDBNull(0))
{
// Get the value from the reader and convert it to a string
string value = reader.GetValue(0).ToString();
// Set the value in the output buffer
Output0Buffer.myNewColumn = value;
}
else
{
// Handle null value as needed
// For example, you can set it to an empty string
Output0Buffer.myNewColumn = string.Empty;
}
}
}
The code is taken from SSIS Script Component - How to modify the Output0Buffer.
Input0_ProcessInputRow(Input0Buffer Row)
. This might seem like a problem, but always there are ways around it. I couldn't quite understand what you are going to do in your code. – Foulness