I am trying to fetch the values in the dropdown from database:-
Server.R
sqlOutput<- reactive({
sqlInput<- paste("select distinct ASSET_CLASS from DUMMY_TABLE")
dbGetQuery(con, sqlInput)
})
UI.R
selectInput('pick_assetclass',label ='Asset Class',choices=sqlOutput(),selected = NULL, multiple = FALSE,width="450px"),
Could you please let me know the error in the code?
Error message:-
Error in lapply(obj, function(val) { :
could not find function "sqlOutput"
Thanks, This is the edited code as per your valuable answers. I see the column names in the dropdown alongwith the filtered values. Could you let me know how to resolve it?
Server.R
sqlOutputAssetClass <- reactive({
sqlInputAssetClass<- paste("select distinct ASSET_CLASS from DUMMY_TABLE",sep="")
dbGetQuery(con, sqlInputAssetClass)
})
sqlOutputFeedSrcSys <- eventReactive(input$pick_assetclass,({
sqlInputFeedSrcSys<- paste("select distinct FEED_SRC_SYS from DUMMY_TABLE where ASSET_CLASS=","'",input$pick_assetclass,"'",sep="")
dbGetQuery(con,sqlInputFeedSrcSys)
}) )
observe ({
updateSelectInput(session,"pick_assetclass","ASSET CLASS",
choices = sqlOutputAssetClass()
)
})
observe ({
updateSelectInput(session,"pick_feedsrcsys","FEED SOURCE SYSTEM",
choices = sqlOutputFeedSrcSys()
)
})
UI.R
selectInput('pick_assetclass',label ='Asset Class',choices=NULL,selected = NULL, multiple = FALSE,width="450px"),
selectInput('pick_feedsrcsys',label ='Feed Src Sys',choices=NULL,selected = NULL, multiple = FALSE,width="450px"),