Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sqlParseVariables

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(conn, sql, ...)

sqlCommentSpec(start, end, endRequired)

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

sqlParseVariablesImpl(sql, quotes, comments)

Arguments

sql

SQL to parse (a character string)

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))
)

DBI

R Database Interface

v1.1.1
LGPL (>= 2.1)
Authors
R Special Interest Group on Databases (R-SIG-DB) [aut], Hadley Wickham [aut], Kirill Müller [aut, cre] (<https://orcid.org/0000-0002-1416-3412>), R Consortium [fnd]
Initial release
2021-01-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.