Creating Dynamic SQL Query in JDBC Data Source

poojasingh
Giga Contributor

We have created a JDBC data source that fetches data from SQL Server. The data it gets is based on correlation_id provided on RITM. For now, we have to manually update the sql query like below:

select * from table where correlation_id IN ('123');

 

If we don't put the where condition, it will be fetching all requests from the server. We want to limit the records to the ones that are currently in ServiceNow. 

Is there a way to pass on these correlation_id dynamically to the sql query? OR any other way to achieve this functionality?

1 REPLY 1

Harsh Vardhan
Giga Patron

i did not test but can you try something like this.

 

select * from table where correlation_id IN (SELECT correlation_id FROM table );