renderSqlFile: Render a SQL file

View source: R/HelperFunctions.R

renderSqlFileR Documentation

Render a SQL file


renderSqlFile Renders SQL code in a file based on parameterized SQL and parameter values, and writes it to another file.


renderSqlFile(sourceFile, targetFile, warnOnMissingParameters = TRUE, ...)



The source SQL file


The target SQL file


Should a warning be raised when parameters provided to this function do not appear in the parameterized SQL that is being rendered? By default, this is TRUE.


Parameter values


This function takes parameterized SQL and a list of parameter values and renders the SQL that can be send to the server. Parameterization syntax:


Parameters are indicated using a @ prefix, and are replaced with the actual values provided in the render call.

{DEFAULT @parameterName = parameterValue}

Default values for parameters can be defined using curly and the DEFAULT keyword.


The if-then-else pattern is used to turn on or off blocks of SQL code.


## Not run: 
renderSqlFile("myParamStatement.sql", "myRenderedStatement.sql", a = "myTable")

## End(Not run)

SqlRender documentation built on Jan. 11, 2023, 5:10 p.m.