SelectInput R shiny

76 Views Asked by At

I am a beginner in R shiny. I use an Oracle database.

I have a table T_Client(CLI_ID, CLI_NAME, CLI_INFO).

I display CLI_NAME from T_CLIENTin selectinput which I used reactive function sqlOutput()

But I can't display all columns from T_CLIENT in the renderTable, the funCtion sqlOutput() doesn't work well.

Any help please ? Thanks in advance.

library(DBI)
library(ROracle)
library(shinydashboard)

header <- dashboardHeader()

sidebar <- dashboardSidebar()

body <- dashboardBody(
  uiOutput("ui_assetClass"),
  tableOutput("table2"))

shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output, session= open()) {
    
    drv <- dbDriver("Oracle")
    host <- "host"
    port <- xxxx
    svc <- "svc"
    connect.string <- paste(
      "(DESCRIPTION=", "(ADDRESS=(PROTOCOL=tcp)(HOST=", host, ")(PORT=", port, "))",
      "(CONNECT_DATA=(SERVICE_NAME=", svc, ")))", sep = "")
    DB <- dbConnect(drv, username = "username", password = "password", dbname = connect.string)
    
    
    sqlOutput<- reactive({
      
   sqlInput<- dbGetQuery(DB,"select CLI_NAME from T_CLIENT")
      
      sqlInput
    })
    
    output$ui_assetClass <- renderUI({
      selectInput(" Clients", "choose client", choices = sqlOutput())
    })
    
    
    dabaBaseInput2 <- reactive({
      x <- dbGetQuery(DB, sprintf("SELECT CLI_ID, CLI_NAME, CLI_INFO FROM T_CLIENT where CL_NOM = '%s' ",sqlOutput()))
      x
    })
    
    output$table2 <- renderTable({
      dabaBaseInput2()
    })
    
  })
0

There are 0 best solutions below