Forum Discussion

N78A's avatar
N78A
Contributor
7 years ago

Hi, I am trying to use a SQL query in JDBC oracle connection test step

Hi, I am trying to  execute SQL query using 'LIKE' operator in JDBC oracle connection test step

 

Details: I have defined property - "yearMonth" in JDBC test step . yearMonth is picking value from test data file (through separate steps)

 

SQL query - 

 

select transaction_id , transaction_date_key
from f_customer_trans_new
where d_customer_key = (select d_customer_key from d_customer_core where nk_customer_number =:customerId)
and transaction_date_key like :yearMonth

 

Now I am not able to fetch results using *Like* operator , original query - 

 

select transaction_id , transaction_date_key
from f_customer_trans_new 
where d_customer_key = (select d_customer_key from d_customer_core where nk_customer_number =:customerId)
and transaction_date_key like '201703%'

this query gives me the result for the dates -  March 2017

 

 

  • nmrao's avatar
    nmrao
    Champion Level 3
    N78A,

    Not sure, but you can try as below:

    Include "%" for the "yearMonth" value. And in the query, just mention parameter name.

    Good luck.
    • N78A's avatar
      N78A
      Contributor

      Hi nmrao,

       

      Thanks a lot for your response!

      But unfortunately I can not use '%' in value because I am fetching the data from test data file (which I am using to run my request) , so adding % in value will make the test data invalid and my request would fail. 

      basically I am trying to fetch the response for the 'customerId' for duration 'yearMonth'.  And then comparing the response with the data present in database for that particular customerId for that duration - yearMonth

       

      anything else you can suggest please ?