简体   繁体   中英

Passing a variable into a stored procedure call using Talend Open Source

I want to call an SP in Talend like the following:

`/ 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;`

Can this be done in Talend Open Source? If so, how?

Check this link, This might be helpful for you.

Calling a stored procedure or function

You can use tMssqlInput() component to call for Stored procedure. In the Query Builder, just type "EXEC your_sp_name '"+context.from_date+"','"+context.to_date+"', "+context.var+"" Before calling stored procedure from tMssqlInput(), you should store the dynamic variable value in the context parameters . Typically your job flow would be like this :

enter image description here

I used tMSSQLInput component but, it didn't work for me.

We can execute SQL Server stored procedure in Talend along with the context variables using tMSSQLRow component. Works like charm for me

But, few things to note:

  1. I gave tMSSQLConnection and then connected it with tMSSQLRow ( with a stored procedure inside this component ). This didn't work.

  2. So I had to remove the tMSSQLConnection and enter the connection details in the tMSSQLRow component itself. This worked for me.

Enter stored procedure in this format:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM