SSIS Script Multiple Input Component

I am looking for a way to create a script component in SSIS that will accept multiple inputs.

I need this so that I can make a user connection form.

It seems really stupid that a script can have multiple exits, but only one input, I'm sure I should do something wrong.

Any help?

+3
source share
3 answers

try adding the Union All component in front of your script component and instead of matching the columns, add the columns to the output so that each element in the queue comes in a unique column.

, SSIS script , , , .

, , script , , , SSIS 2005.

+1

SSIS script . clumsey, script , System. Threading script .

, script ( SSIS). , , ( ) [], ManualResetEvent, SSIS PipelineBuffer .

, script script, , , .

, , ( ) SSIS "ProcessInput" script. , SO, , , [clumsey], script.

?

---- EDIT ----

- , ProcessInput . , :

Script 1: ...

using System;
using System.Collections;
using System.Threading;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Dts.Pipeline;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{


    System.Collections.Generic.List<object> shared = null;
    System.Threading.ManualResetEvent sync;

    public override void ProcessInput(int InputID, PipelineBuffer Buffer)
    {
        lock (this)
        {
            if (InputID == 82)
            {
                if (shared == null)
                {
                    shared = new System.Collections.Generic.List<object>();
                    sync = new System.Threading.ManualResetEvent(false);
                    shared.Add(sync);
                    shared.Add(Buffer);
                    shared.Add(GetColumnIndexes(InputID));

                    IDTSVariables100 vars = null;

                    this.VariableDispenser.LockOneForWrite("Test", ref vars);

                    vars[0].Value = shared;
                    vars.Unlock();
                    sync.WaitOne();
                    System.Windows.Forms.MessageBox.Show("Done");
                }
            }
        }
    }
}

... script 2 ( script 1)...

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
    System.Threading.ManualResetEvent sync = null;
    InputXBuffer sharedBuffer = null;

    public override void Input0_ProcessInput(Input0Buffer Buffer)
    {
        lock (this)                 // Only 1 thread at a time
        {
            if (sharedBuffer == null)
            {
                object Test = null;
                while (Test == null)
                {
                    System.Threading.Thread.Sleep(100);
                    IDTSVariables100 vars = null;
                    this.VariableDispenser.LockOneForRead("Test", ref vars);
                    Test = vars[0].Value;
                    vars.Unlock();
                }

                var sharedList = Test as System.Collections.Generic.List<object>;

                if (sharedList != null)
                {
                    sync = sharedList[0] as System.Threading.ManualResetEvent;
                    var buffer = sharedList[1] as PipelineBuffer;
                    var bufferColumnIndexes = sharedList[2] as int[];
                    sharedBuffer = new InputXBuffer(buffer, bufferColumnIndexes);
                }
            }
       }

        while (sharedBuffer.NextRow())
        {
            // ... do stuff with Script Component 1 shared input here...
        }
        sync.Set();     // Signal script 1 that we're done
    }
}

script / "" - . , .

PS: - , SSIS .

0

, , UNION ALL, .

.

  1. ADO

  2. , ADO.

  3. , , .
0
source

Source: https://habr.com/ru/post/1706892/


All Articles