SQL query to postgres DB failing when using dynamic values

  • Goal: I want to send an update to the DB every time a cell is edited. I use a dynamic query that looks like this:
UPDATE table
SET "{{table13.selectedCell.columnId}}" = '{{table13.selectedCell.value}}'
WHERE id = {{table13.selectedRow.id}};

The Retool editor popup says that the query would like like this:

UPDATE table
SET "country" = 'GB'
WHERE id = 1;

And this query works when run manually in the database.

  • Steps: I have tried to change the inverted commas on every bt of the query, i have tried removing all inverted commas.

  • Details: The column definitely exists in the table. I have tested the query created by retool manually, but when run by retool it fails with error: column "$1" of relation "table" does not exist

  • Screenshots:

  • App json export:

Hey @pietrocapece,

You may find answers to what you're facing here, and a potential solution here.

Hope this helps!

1 Like

Thank you! I ended up using the GUI to do th query in the end, and it worked.

1 Like