Your SQL syntax of the IN clause is not right; you need to have the values in brackets.
I believe this will work better, though I can not really reproduce your code
server <- function(input, output) {
output$query <- renderText({
glue ("
select cod_ordem_producao
from pla.cod_ordem_producao
WHERE cod_ordem_producao IN ({input$ordemlista})
")
})
When debugging the where clause should look somewhat like WHERE cod_ordem_producao IN ('LQ', 'LQR') or what not - individual values in single quotes, separated by commas, the whole set in brackets.
Thanks @andresrcs! I did not have a working Shiny on hand when I was composing the reply - but by looking at your SQL code: yes, this is what I had in mind
The solution worked, because it managed to collapse the vector of selected ordemlistas from a vector to a single string value; that is what the paste() is there for.
You needed a string that would start with an opening bracket and a single quote, contain all the ordemlistas values in single quotes and separated by commas, and then end with another single quote and a closing bracket.
The slashes are escape character, as you need a trick to use single quotes within the query string (normally a single quote could signal the end of the string).
input <- data.frame(ordemlista= c("a", "b", "c"),
stringsAsFactors=FALSE)
# This is a character vector of length 3
input$ordemlista
#> [1] "a" "b" "c"
length(input$ordemlista)
#> [1] 3
# This is a string or a character vector of lenght 1
string <- paste(input$ordemlista, collapse = "', '")
string
#> [1] "a', 'b', 'c"
length(string)
#> [1] 1