hirosht
hirosht

Reputation: 982

Parameterize a JDBC SQL Query in SOAP UI from a Custom Property

To proceed with a Database validation, I am having a need of comparing a record in the DB along with a data which is dynamically generated in the previous REST response, using SoapUI.

I have already captured the property value using a Property Transfer step and stored the required value in a custom property in Test-Case successfully i.e., using property expansion, say ${TestCase#customerId}

My intention is to use that particular value stored in the custom properties to query the result I am expecting, in the JDBC Request test step.

The query which I have drafted with the parameter is as below :

Select * 
From ABC.SEC_CUST
Where ABC.SEC_CUST.CUSTOMER_ID =  ${TestCase#customerId} 

The response I receive after executing is as below.

Error getting response; java.sql.SQLSyntaxErrorException : ORA-00911: Invalid character.

But, when I run the query without the parameterized value it executes perfectly. Where, I tend the conclusion as there is a syntax issue in the way I have mentioned the parameter in the query.

But, I am unable to find the correct way to mention the parameter in the query in SoapUI.

Can anyone with experience in SoapUI, please assist me on this?

Upvotes: 3

Views: 6185

Answers (4)

Marcell
Marcell

Reputation: 949

Like mentioned by others you simply forgot a '#' in the parameter name.

To avoid such mistakes use the built-in context menu of the "SQL Query" text field. It has a menu entry called "Get Data..." which lets you insert all known properties into the SQL statement.

Upvotes: 0

Tom
Tom

Reputation: 106

You forgot a '#'

Select * 
From ABC.SEC_CUST
Where ABC.SEC_CUST.CUSTOMER_ID =  ${#TestCase#customerId} 

Upvotes: 2

Rao
Rao

Reputation: 21389

That is not working because of the use of property expansion which is only known to SoapUI, but not for the SQL query.

In order to get it work for the same, you need to define the variables in the top for all the parameters that are going to be used in the sql query.

Here the screen shot which explains how to use the same:

enter image description here

Upvotes: 7

KJTester
KJTester

Reputation: 407

Try this.

Select * From ABC.SEC_CUST
Where ABC.SEC_CUST.CUSTOMER_ID = :customerId

Upvotes: 0

Related Questions