What is the error that is being encountered? In straight up Tableau, we prevent writing/altering sql entirely so this is an interesting work around if you are getting it to function as desired.
My code works in R when I run it, so I know this is correct R code. Below is the error code I am getting in my calculated field. I believe it is erroring out because of the quotation marks in the SQL update statement, when I change those to single quotes the error msg goes away, however, it is not valid R code so it will not execute correctly.
The simplest workaround I can think of is for you to turn your R code for the update into a library with the desired values as arguments and then you can load that library either when starting Rserve (better performance but leaving a security hole) or in the Tableau call to R.
One note on using Tableau's R integration to do write back is that Tableau calls R for many types of view updates. Refreshes, changing filters, and changing parameters are the big three. This will lead to the SQL update being executed again and again unless you do something fancy to add some sort of checking for current/prior state. The JS API could theoretically let you avoid this issue, but that has its own complexities.
Sent from my iPhone
Thank you, I will give this a try or going with the API. Thank you for your responses
This discussion is long time ago, and I am not sure if you still remember this case.
I also kind of run into similar problem that users request to write comments back into SQL databases. Can you share with me how you design the dashboard and how to use the R codes in Tableau?
Appreciate your help!