How to pass dynamic list of ids to name query params


Like as code below I’d like to delete dynamic number of Ids from a table by using name query and I’d like to pass the ids list as params but I can’t figure it out how to pass a list to name query.

DELETE FROM dependents
employee_id IN (100 , 101, 102);

You can’t do it in a named query. You need to dynamically construct a “Prep” query in a script (with the correct number of question marks) to do this with safe parameters.

1 Like

I do it in SELECT named queries all the time, it might work for deletes too.

Define a QueryString, employee_ids, of type String and adjust your where clause.

WHERE employee_id IN ({employee_ids})

That’s using a querystring, not a safe value parameter. Not the same thing at all.

To be fair, the OP didn’t ask for a safe way, just if there was a way. :slight_smile: