postgresql dynamic params
when running a postgres type script (which i understand is rust under the hood)
I am unable to utilize dynamic params when running.
sample script:
-- $1 name1 = 1 hours
SELECT user_id
FROM replica_views.player_view
WHERE user_id IS NOT NULL
AND created_at >= NOW() - INTERVAL "$1::TEXT";
it does work when it's like INTERVAL '1 hours';
also tried it without casting any type. and when moving quotes to input instead of code
also when using single quotes it just returns a null value.
this is the error.
ExecutionErr: error during execution of the script:
Error: db error: ERROR: syntax error at or near "$1": ERROR: syntax error at or near "$1" @handle_child.rs:528:16
should I open a bug, or is it a user error?
2 Replies
doesn't look like correct pg
chatgpt can help you write prepared statements
but yeah "$1::TEXT" is not correct
yeah without quotes i was able to utilize params e.g. WHERE user_id = $1::INT;
i'll try to wrap my head around it. Jenkins groovy dsl is way worse lol 😄