I’m new to N8N and it is looking promising. I’m trying to get a postgres query working with some variables. like select * from tenant where tenant is $1;
in the query parameters I pass in a value, but I never get any result (always empty)
if I hardcode the the tenant to a value in the query it is working, only not if I specify this via the query parameters.
What is the error message (if any)?
no errors, just no data
Please share the workflow
Share the output returned by the last node
Information on your n8n setup
n8n version:
Database you’re using (default: SQLite):
Running n8n with the execution process [own(default), main]:
Hi @Edward, welcome to the community! n8n would populate the query parameters using incoming data. So the Query Parameters field expects the name of one (or more) incoming fields like so:
I was using an expression to get the value, but that seems not to work. although the expression editor was showing the correct result.
Does this mean that for postgres you only should use the input fields directly and not via expressions?
You can use expressions if you like, but I wouldn’t recommend it as it is a possible SQL injection vector. To use expressions, you would need to add them directly in the Query field rather than through parameters:
So instead you might want to consider first using a Set node for your expressions, and only then use query parameters in the Postgres node itself.