I am currently working on a shiny application for work that is partially based off of this tutorial by Niels van der Velden. I am running into issues with the following code chunk:
observeEvent(input$submit_edit, priority = 20, {
SQL_df <- dbReadTable(pool, "responses_df")row_selection <- SQL_df[input$responses_table_row_last_clicked, "row_id"]dbExecute(pool, sprintf('UPDATE "responses_df" SET "name" = ?, "sex" = ?, "age" = ?,"comment" = ? WHERE "row_id" = ("%s")', row_selection),param = list(input$name,input$sex,input$age,input$comment))removeModal()
})
The code is supposed to execute an SQL query which updates the database to reflect changes made in a dialog box. When used with RSQLite, this code works just fine. However, when using RPostgres, I receive the following error:
Warning: Error in : Failed to prepare query: ERROR: syntax error at or near ","
LINE 1: UPDATE "responses_df" SET "name" = ?, "sex" = ?, "age" = ...
^
I have tried replacing the ? parameters with $ ones in the hope that this was a simple syntax difference, but that leads to the following error:
Warning: Error in : Failed to prepare query: ERROR: syntax error at or near "$"
LINE 1: UPDATE "responses_df" SET "name" = $, "sex" = $, "age" = ...
^
Edit: Fixed names for consistency.