updateSQLwithParams: Parameterised SQL.

Description Usage Arguments Value Note See Also Examples

View source: R/dbUtilities.R

Description

The core parameter replacement function accepting a list of parameter names to replace and replacing all the occurances in x that have @......

Usage

1
updateSQLwithParams(x, dataConfig)

Arguments

x

A string that represents a query with @paramName to be replaced.

dataConfig

The configuration list, where the names represent the parameter and the values are what will be replaced.

Value

A string that represents an SQL query.

Note

Dates have to use the format that is expected by SQL.

See Also

format, dbGetQuery

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
updateSQLwithParams("select * from @table", list(table = "blah"))

query.txt<-"
select
   sum(total_sales_amount) as spend
   ,transaction_date
from
   cedwdm.transaction_product_vw
where
   transaction_date > '@start.date'
group by
   transaction_date
"
my.query<-updateSQLwithParams(
   query.txt
   , list(start.date = format(Sys.Date() - 7, "%d-%b-%Y" ))
   )
print(my.query)

ivanliu1989/RQuant documentation built on Sept. 13, 2019, 11:53 a.m.