Description Usage Arguments Details Tagged Comments Note See Also Examples
Activates (uncomments) Part of a SQL Template based on supplied data.
1 2 3 4 5 6 7 8 | sql_activate(
x,
tags = if (!is.null(getOption("sql.tags"))) getOption("sql.tags") else "",
block = TRUE,
inline = TRUE
)
sql_uncomment(...)
|
x |
character or sql object; if character, it is first coerced to SQL |
tags |
character; tags that should be uncommenting. The default
is |
block |
logical; uncomment block (/* ... */) comments. Default: TRUE |
inline |
logical; uncomment inline (– ...) comments. Default: TRUE |
sql_activate
is not the same as
sql_strip_comments()
which completely removes comments from a
SQL statement.
sql_activate
removes comment delimiters so that comments
that normally skipped will be evaluated by a SQL engine.
By default, all comments are uncommented, setting the global
option sql.tag
or passing an argument to tags
will uncomment
only tagged comments.
Tagged comments allow the user to implement additional functionality at run-time. This allows queries to be shared by multiple functions. For example, a query might be used in a bulk operation operating on all records or an iterative procedure where a subset of records are used.
Comments are uncommeted by tags. By default, the tag is ""
, namely all
comments. A common case is to have a part of the where clause be for
development. For example,
–dev: AND user_id = 1 or /*dev: AND user_id = 1 */.
Comments can be tagged in the SQL code, by placing the tag as the first letter type character(s) of the query followed by a colon. For example:
inline: --tag_name:
block: /*tag_name:*/
A comment can only have one tag.
This interface may change in the future.
Todo: Fixes white-space problems related to uncommenting.
1 2 3 4 5 | sql <- "SELECT \n col a \n --, col b \n FROM table"
sql_activate( sql )
sql <- "SELECT col a /*, col b */ FROM table"
sql_activate( sql )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.