registerStoredProcedure: 데이터베이스에 SQL 저장 프로시저 등록

registerStoredProcedure: StoredProcedure 개체를 사용하여 지정된 데이터베이스에 저장 프로시저를 등록합니다.

사용

  registerStoredProcedure(sqlSP, connectionString = NULL)

인수

sqlSP

유효한 StoredProcedure 개체

connectionString

문자열입니다(연결 문자열 없이 StoredProcedure 개체가 생성된 경우 제공해야 함).

성공하면 TRUE이고, 실패하면 FALSE


 ## Not run:

# See ?StoredProcedure for creating the "cleandata" table.

# train 1 takes a data frame with clean data and outputs a model
train1 <- function(in_df) {
 in_df[,"DayOfWeek"] <- factor(in_df[,"DayOfWeek"], levels=c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"))
 # The model formula
 formula <- ArrDelay ~ CRSDepTime + DayOfWeek + CRSDepHour:DayOfWeek
 # Train the model
 rxSetComputeContext("local")
 mm <- rxLinMod(formula, data=in_df)
 mm <- rxSerializeModel(mm)
 return(list("mm" = mm))
}
# create InpuData Object for an input parameter that is a data frame
# note: if the input parameter is not a data frame use InputParameter object
id <- InputData(name = "in_df",
              defaultQuery = paste0("select top 10000 ArrDelay,CRSDepTime,",
                                    "DayOfWeek,CRSDepHour from cleanData"))

# create an OutputParameter object for the variable inside the return list
# note: if that variable is a data frame use OutputData object
out <- OutputParameter("mm", "raw")

# connections string
conStr <- paste0("Driver={ODBC Driver 13 for SQL Server};Server=.;Database=RevoTestDB;",
                "Trusted_Connection=Yes;")
# create the stored procedure object
sp_df_op <- StoredProcedure("train1", "spTest1", id, out,
                       filePath = ".")
# register the stored procedure with the database
registerStoredProcedure(sp_df_op, conStr)
model <- executeStoredProcedure(sp_df_op, connectionString = conStr)

# Getting back the model by unserializing it.
mm <- rxUnserializeModel(model$params$op1)
## End(Not run)