Learn R Programming

RODBCext (version 0.3.2)

sqlPrepare: Prepares a query for execution

Description

Prepares a query for execution.

Usage

sqlPrepare(channel, query, errors = TRUE, query_timeout = NULL)

Arguments

channel

ODBC connection obtained by odbcConnect

query

query string

errors

whether to display errors

query_timeout

the query timeout value in seconds (0 means "no timeout", NULL does not change the default value)

Value

invisible(1) on success, -1 or an error (depending on errors parameter) on error

Examples

Run this code
# NOT RUN {
  conn = odbcConnect('MyDataSource')
  
  sqlPrepare(conn, "SELECT * FROM myTable WHERE column = ?")
  sqlExecute(conn, NULL, 'myValue')
  sqlFetchMore(conn)
  
  # with a query timeout
  sqlPrepare(conn, "SELECT * FROM myTable WHERE column = ?", query_timeout=60)
  sqlExecute(conn, data='myValue', fetch=TRUE)
# }

Run the code above in your browser using DataLab