BIML Parameterized Ole db Source Request

I am creating several SSIS packages with BIML and I need to get data from an OLE DB source between the date interval. Here is the xml that will generate the packages:

<Dataflow Name="DFT Insert into <#=TableName#>">
    <Transformations>
        <OleDbSource Name="Retreive from Source (<#=TableName#>)" ConnectionName="AS400">
            <DirectInput>
                SELECT s.* 
                FROM <#=TableSchema#>.<#=TableName#> s
                WHERE s.date &gt; ? AND s.date &lt;= ?
            </DirectInput>
            <Parameters>
                <Parameter Name="0" VariableName="User.StartDate"/>
                <Parameter Name="1" VariableName="User.MiddleDate"/>
            </Parameters>
        </OleDbSource>

        <OleDbDestination Name="Insert into Destination (<#=TableName#>)" ConnectionName="DB2Mirror" KeepNulls="true" CheckConstraints="false">
            <ExternalTableOutput Table="[<#=TableSchema#>].[<#=TableName#>]" />
        </OleDbDestination>   
    </Transformations>
</Dataflow>

This structure usually works because I already tried it, but with identifiers (int) instead of dates (strings). The error I get when trying to generate a package is as follows:

Could not execute Query on Connection AS400
OleDbCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.

I know that I could create the ssis variable and combine the dates in the query as an expression, but I would like to stick <DirectInput>instead<VariableInput>

Additional Information

datetime (, , datetime, , ) : yyyy-mm-dd hh: mm: ss. , , , : <Variable Name="Query" DataType="String" EvaluateAsExpression="true">&quot;SELECT * FROM table WHERE col &gt; '&quot; + @[User::StartDate] + &quot;'&quot;</Variable> . , , , dbms db2

+6
1

CREATE TABLE dbo.so_42623962
(
    RowSk int NOT NULL
,   [Date] date
);

, Biml, OLE DB Sources

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
    <OleDbConnection Name="tempdb" ConnectionString="Data Source=localhost\dev2016;Initial Catalog=tempdb;Provider=SQLNCLI11.0;Integrated Security=SSPI;"/>
</Connections>
<Packages>
    <Package Name="so_42623962" >
        <Variables>
            <Variable Name="StartDate" DataType="String">2017-01-01</Variable>
            <Variable Name="MiddleDate" DataType="String">2017-01-01</Variable>
        </Variables>
        <Tasks>
            <Dataflow Name="DFT Demo">
                <Transformations>
                    <OleDbSource Name="SRC Query" ConnectionName="tempdb">
                        <DirectInput><![CDATA[SELECT * 
                        FROM dbo.so_42623962 AS X 
                        WHERE X.[Date] > ? AND X.[Date] <= ? ;]]></DirectInput>
                        <Parameters>
                            <Parameter Name="0" VariableName="User.StartDate" />
                            <Parameter Name="1" VariableName="User.MiddleDate" />
                        </Parameters>
                    </OleDbSource>
                    <DerivedColumns Name="DER Placeholder" />
                </Transformations>
            </Dataflow>
        </Tasks>
    </Package>
</Packages>
</Biml>

. CDATA, , /, ,

        <Dataflow Name="DFT Escaped">
            <Transformations>
                <OleDbSource Name="SRC Query" ConnectionName="tempdb">
                    <DirectInput>SELECT * 
                    FROM dbo.so_42623962 AS X 
                    WHERE X.[Date] &gt; ? AND X.[Date] &lt;= ?;</DirectInput>
                    <Parameters>
                        <Parameter Name="0" VariableName="User.StartDate" />
                        <Parameter Name="1" VariableName="User.MiddleDate" />
                    </Parameters>
                </OleDbSource>
                <DerivedColumns Name="DER Placeholder" />
            </Transformations>
        </Dataflow>

Date ,

        <Dataflow Name="DFT Escapedx2">
            <Transformations>
                <OleDbSource Name="SRC Query" ConnectionName="tempdb">
                    <DirectInput>SELECT * 
                    FROM dbo.so_42623962 AS X 
                    WHERE X.Date &gt; ? AND X.Date &lt;= ?;</DirectInput>
                    <Parameters>
                        <Parameter Name="0" VariableName="User.StartDate" />
                        <Parameter Name="1" VariableName="User.MiddleDate" />
                    </Parameters>
                </OleDbSource>
                <DerivedColumns Name="DER Placeholder" />
            </Transformations>
        </Dataflow>

, ? - (/ ). yyyy-mm-dd aka ccyy-mm-dd, , , , ISO yyyymmdd.

, , AS400. , "" , , , AS400 CYMD, " ", , yyyy-mm-dd CYMD. , , .

+3

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


All Articles