GLUE package error in input values

Hello guys,

I need your help regarding an error in R.

I'm using GLUE package to make a search on my DB (Oracle), and it works very well when I put the value directly into the code, like above:

 ...                                      
      
      where  
      
      pla.cod_pedido = '0000545461'     <--------------
      and pla.cod_item = '000010'          <-------------
      and    pla.cod_ordem_producao = ro.cod_ordem_producao

BUT, when i change this value to a numeric INPUT, like:

 ...                                      
 
      where  
      
      pla.cod_pedido = {as.numeric(input$pedido)}        <--------------
      and pla.cod_item = {as.numeric(input$item)}         <-------------
      and    pla.cod_ordem_producao = ro.cod_ordem_producao

It does not work. I'm using the same values for both of the input's.

I think i can be a syntax error, but i don't have sure.

UI

numericInput("pedido")
numericInput("item")

In the hard coded query you are using text values i.e. '0000545461' but in the other query you use as.numeric() this would give 54546 do you see the difference? Classes just don't match.

I need use a string input?

input$pedido already returns a character value, if the class of pla.cod_pedido is also character, then just don't use as.numeric().

But the class of pla.cod_pedido is numeric

Well that doesn't make much sense since you are saying that this works for you

pla.cod_pedido = '0000545461'

Your are comparing to a character string (numeric values don't have leading zeros)

So for using character data as input I need use what type of input?

Because I'm testing:

  • SERVER

...

  where  
  
  pla.cod_pedido = {(input$pedido)}        <--------------
  and pla.cod_item = {(input$item)}         <-------------
  and    pla.cod_ordem_producao = ro.cod_ordem_producao
  • UI

numericInput("pedido")
numericInput("item")

but It does not work.

It's hard to know without a Reproducible Example,
but Im guessing that input$pedido returns a value without the leading zeros like '54546' and since you are comparing to a character string obviously they don't match, you could use stringr::str_pad() to add the leading zeros.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.