First of all, I need to use R to get SQL query result from HANA database, which I finish by using RODBC in Rstudio.
Second of all, I need to share my code with others, which I use shinyapps.io to finish.
error first argument is not an open rodbc channelHere is my codes for ui.R and sever.R attached:
library(dplyr)
library(RODBC)
library(stringr)
library(ggplot2)
fluidPage(
titlePanel("Basic DataTable"),
fluidRow(
DT::dataTableOutput("table")
)
)library(dplyr)
library(RODBC)
library(stringr)
library(ggplot2)
ch<-odbcConnect('HANARB1P',uid='****',pwd='****')
options(scipen = 200)
myOffice <- 0
StartDate <- 20170601
EndDate <- 20170610
office_clause = ""
if (myOffice != 0) {
office_clause = paste(
'AND "_outer"."/BIC/ZSALE_OFF" IN (',paste(myOffice, collapse=", "),')'
)
}
function(input, output) {
output$table <- DT::renderDataTable(DT::datatable({
data <- sqlQuery(channel=ch,query=paste(' SELECT TOP 100
"/BIC/ZSALE_OFF" AS "SalesOffice",
"/BIC/ZHASHPAN" AS "CreditCard"
FROM "SAPB1P"."/BIC/AZ_RT_A212"
WHERE "CALDAY" BETWEEN',StartDate,'AND',EndDate,'
',office_clause,'
'))
data
}))Could anyone please help me out here? How to use shinyapps.io and RODBC to show the SQL query result on the webpages for sharing?