Learn R Programming

RMySQL (version 0.4-6)

dbExec: Execute an SQL script on a given database connection

Description

Submits and executes an arbitrary SQL script (one or more statements) on a specific connection.

Usage

dbExec(con, statement, ...)

Arguments

con
a connection object (i.e., an object that extends dbConnection).
statement
a character vector with one or more SQL statements.
...
database-specific parameters may be specified.

Value

  • an object that extends dbResult, in the case of an SQL statement that produces no output (e.g., INSERT), or dbResultSet in the case of a SELECT-like statement.

Side Effects

The statements are submitted to the server connected through the connection con.

Bugs

Current implementations can only handle one-statement scripts.

References

See the Omega Project for Statistical Computing at http://www.omegahat.org for more details on the R/S database interface.

Details

This function submits and executes SQL scripts, i.e., one or more SQL statements, to the database engine. To fetch records you need to use the function fetch. Currently it is undefined how multiple result sets are to be processed.

See Also

On database managers:

dbManager MySQL load unload

On connections, SQL statements and resultSets:

dbExecStatement dbExec fetch quickSQL

On transaction management:

commit rollback

On meta-data:

describe getVersion getDatabases getTables getFields getCurrentDatabase getTableIndices getException getStatement hasCompleted getRowCount getAffectedRows getNullOk getInfo

Examples

Run this code
mgr <- dbManger("MySQL")
con <- dbConnect(mgr)
rs <- dbExecStatement(con, "SELECT * from liv25")
data <- fetch(rs, n = -1)

Run the code above in your browser using DataLab