Last data update: 2014.03.03

R: Parse interpolated variables from SQL.
sqlParseVariablesR Documentation

Parse interpolated variables from SQL.

Description

If you're implementing a backend that uses non-ANSI quoting or commenting rules, you'll need to implement a method for sqlParseVariables that calls sqlParseVariablesImpl with the appropriate quote and comment specifications.

Usage

sqlParseVariables(con, sql, ...)

## S4 method for signature 'DBIConnection'
sqlParseVariables(con, sql, ...)

sqlCommentSpec(start, end, endRequired)

sqlQuoteSpec(start, end, escape = "", doubleEscape = TRUE)

sqlParseVariablesImpl(sql, quotes, comments)

Arguments

sql

SQL to parse (a character vector of length 1)

start, end

Start and end characters for quotes and comments

endRequired

Is the ending character of a comment required?

escape

What character can be used to escape quoting characters? Defaults to "", i.e. nothing.

doubleEscape

Can quoting characters be escaped by doubling them? Defaults to TRUE.

quotes

A list of QuoteSpec calls defining the quoting specification.

comments

A list of CommentSpec calls defining the commenting specification.

Examples

# Use [] for quoting and no comments
sqlParseVariablesImpl("[?a]",
  list(sqlQuoteSpec("[", "]", "\", FALSE)),
  list()
)

# Standard quotes, use # for commenting
sqlParseVariablesImpl("# ?a\n?b",
  list(sqlQuoteSpec("'", "'"), sqlQuoteSpec('"', '"')),
  list(sqlCommentSpec("#", "\n", FALSE))
)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DBI)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DBI/sqlParseVariables.Rd_%03d_medium.png", width=480, height=480)
> ### Name: sqlParseVariables
> ### Title: Parse interpolated variables from SQL.
> ### Aliases: sqlCommentSpec sqlParseVariables
> ###   sqlParseVariables,DBIConnection-method sqlParseVariablesImpl
> ###   sqlQuoteSpec
> ### Keywords: internal
> 
> ### ** Examples
> 
> # Use [] for quoting and no comments
> sqlParseVariablesImpl("[?a]",
+   list(sqlQuoteSpec("[", "]", "\", FALSE)),
+   list()
+ )
$start
integer(0)

$end
integer(0)

> 
> # Standard quotes, use # for commenting
> sqlParseVariablesImpl("# ?a\n?b",
+   list(sqlQuoteSpec("'", "'"), sqlQuoteSpec('"', '"')),
+   list(sqlCommentSpec("#", "\n", FALSE))
+ )
$start
integer(0)

$end
integer(0)

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>