【问题标题】:Passing a variable into a stored procedure call using Talend Open Source使用 Talend Open Source 将变量传递到存储过程调用
【发布时间】:2017-03-30 11:34:55
【问题描述】:

我想在 Talend 中调用 SP,如下所示:

`/ Declare a variable that references the type. /  
DECLARE @LocationTVP AS LocationTableType;




/ Add data to the table variable. /  
INSERT INTO @LocationTVP (LocationName, CostRate)  
    SELECT Name, 0.00  
    FROM AdventureWorks2012.Person.StateProvince;  



/ Pass the table variable data to a stored procedure. /  
EXEC usp_InsertProductionLocation @LocationTVP;`

这可以在 Talend Open Source 中完成吗?如果有,怎么做?

【问题讨论】:

  • 您尝试过 tYourDBSP 组件吗?它们可用于进行一些存储过程调用。

标签: sql stored-procedures talend edi


【解决方案1】:

您可以使用 tMssqlInput() 组件来调用存储过程。 在查询生成器中,只需键入 "EXEC your_sp_name '"+context.from_date+"','"+context.to_date+"', "+context.var+"" 在从 tMssqlInput() 调用存储过程之前,您应该将动态变量值存储在上下文参数中。 通常你的工作流程是这样的:

enter image description here

【讨论】:

    【解决方案2】:

    我使用了 tMSSQLInput 组件,但它对我不起作用。

    我们可以使用 tMSSQLRow 组件在 Talend 中执行 SQL Server 存储过程以及上下文变量。对我来说就像魅力一样

    但是,有几点需要注意:

    1. 我提供了 tMSSQLConnection,然后将其与 tMSSQLRow 连接(在此组件中使用存储过程)。这不起作用。

    2. 所以我不得不删除 tMSSQLConnection 并在 tMSSQLRow 组件本身中输入连接详细信息。这对我有用。

    以这种格式输入存储过程:

    "EXEC schema_name.procedure_name " '"+context.argument1+"','"+context.argument2+"'

    【讨论】:

      【解决方案3】:

      检查此链接,这可能对您有所帮助。

      Calling a stored procedure or function

      【讨论】:

        猜你喜欢
        • 2015-04-05
        • 1970-01-01
        • 1970-01-01
        • 2011-09-15
        • 1970-01-01
        • 1970-01-01
        • 2020-05-08
        • 2011-06-21
        • 1970-01-01
        相关资源
        最近更新 更多