executeSql: Execute SQL code

Description Usage Arguments Details Examples

Description

This function executes SQL consisting of one or more statements.

Usage

1
2
executeSql(connection, sql, profile = FALSE, progressBar = TRUE,
  reportOverallTime = TRUE)

Arguments

connection

The connection to the database server.

sql

The SQL to be executed

profile

When true, each separate statement is written to file prior to sending to the server, and the time taken to execute a statement is displayed.

progressBar

When true, a progress bar is shown based on the statements in the SQL code.

reportOverallTime

When true, the function will display the overall time taken to execute all statements.

Details

This function splits the SQL in separate statements and sends it to the server for execution. If an error occurs during SQL execution, this error is written to a file to facilitate debugging. Optionally, a progress bar is shown and the total time taken to execute the SQL is displayed. Optionally, each separate SQL statement is written to file, and the execution time per statement is shown to aid in detecting performance issues.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
connectionDetails <- createConnectionDetails(dbms = "mysql",
                                             server = "localhost",
                                             user = "root",
                                             password = "blah",
                                             schema = "cdm_v4")
conn <- connect(connectionDetails)
executeSql(conn, "CREATE TABLE x (k INT); CREATE TABLE y (k INT);")
dbDisconnect(conn)

## End(Not run)

fagirtmi/DatabaseConnector documentation built on May 16, 2019, 9:58 a.m.