Question

How to pass pipeline parameter to jdbc query in streamsets

  • 25 October 2022
  • 5 replies
  • 53 views

I have pipeline parameter name run_id = 123 in configuration and inside jdbc query i want to pass following query:

SELECT * FROM test WHERE id = ${run_id}

 


5 replies

Userlevel 2
Badge

Hi @la_treb2,

I guess you are using JDBC Query Consumer as origin stage, if that is the case, the way you are doing should be correct.

Are you getting any errors out of that?

org.postgresql.util.PSQLException: ERROR: column "de89higjl-2fdf-4a9c-9447-01cacc661e0d" does not exist. Where "de89higjl-2fdf-4a9c-9447-01cacc661e0d" is a value of run_id parameter.

The issue was, beacues i have passed run_id in parametr in double quotes but only one quotes is allowed...

Userlevel 2
Badge

That’s great, thank you for posting the solution too!

Userlevel 5
Badge +1

@la_treb2 

 

If run_id  value is a number then we don’t need quote for numbers and if its a string value then we have to put into in single quote.

 

SELECT * FROM test WHERE id = ${run_id}. ( If the run_id is a number)

 

SELECT * FROM test WHERE id = ‘${run_id}’ (If run id is a string)

Reply