node-sql-template-strings icon indicating copy to clipboard operation
node-sql-template-strings copied to clipboard

How to call stored procedure with dynamic arguments?

Open rightaway opened this issue 6 years ago • 2 comments

How can I call select * from stored_procedure('arg1', 'arg2', 'arg3') with a dynamic number of args? So I would have an array of arguments like args = ['arg1', 'arg2', 'arg3') that I'd like to pass to the sql-template-string, how can it be done? Could there be something like select * from stored_procedure(${args})?

rightaway avatar Mar 24 '18 12:03 rightaway

How would you do it without sql template strings?

felixfbecker avatar Mar 24 '18 16:03 felixfbecker

Basically prepare a string with the length of args, like select * from stored_procedure($1, $2, $3), then pass in the args as the other parameter. I wonder if there could be a simpler way that template strings could offer for such purpose.

rightaway avatar Mar 25 '18 21:03 rightaway