Ask a Question

How to send parameter value to sql query from a datasource ( excel )

Bishal
Contributor

How to send parameter value to sql query from a datasource ( excel )

Hello Guys,

 

I am facing a bit of a challenge here. Hopefully i can explain it better. I am setting my test case as below

1. Datasource-- excel

2. JDBC Request - Sql server ( Simple sql query with parameter )

3. Rest API Call

4. DataSource loop

 

The data source has input parameter for both SQL and API. I first want to call the sql with the parameter that has been send through excel. Then, i want to call the rest API, through the parameter that has been via excel and then compare the data against SQL scripts. Then, loop back to the data-source and go to row 2 for different parameter. 

 

The challenge that i having is not able to parameterzise SQL query .

 

My query is like

 

Declare @name varchar(4) 
Declare @YearMonth Varchar(6)

 

Select  Top .................

from ........

join......

on...

join ..

on...

where name = @name

and YearMonth = @YearMonth

 

what i want to do is send the value of name and YearMonth through excel..

I have created the JDBC request and the property but i am not able to pass the value

 

something like ( property )

Name 

@name                  ${DataSource#@name}  

@YearMonth        ${DataSource#@YearMonth

 

and when i pass it to my sql nothing works and i get an error. ( java.lang.IllegalArguemntException : Parameter '@name' was not found in the SQL Query

 

 

Declare @name varchar(4)  = ${DataSource#@name}
Declare @YearMonth Varchar(6) =  ${DataSource#@YearMonth

 

Select  Top .................

from ........

join......

on...

join ..

on...

where name = @name

and YearMonth = @YearMonth

 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: