Description Usage Arguments Details Functions Examples
The function QuerySauce
and it's helper WhereSauce
provide the
the ability to effortlessly build a valid sql query string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | QuerySauce(tbl = NULL, top = NULL, cols = NULL, wh = NULL,
where = NULL, verbose = FALSE)
WhereSauce(...)
OpsDT()
QueryTree(ll)
ColSauce(...)
AND(wh, string)
OR(wh, string)
not(...)
Qsauce(tbl = NULL, top = NULL, cols = NULL, wh = NULL, where = NULL,
verbose = FALSE)
Wsauce(...)
op(x)
ch_op(x)
lop(x)
clop(x)
rop(x)
crop(x)
revop(x)
|
tbl |
A character string that represents the sql tablename to query |
top |
A numeric value indicating whether to return the top N rows from the query execution |
cols |
An optional character vector specifying columns to return. If not provided, all columns will be returned |
wh |
The output from a call to WhereSauce. A character string representing a valid where clause |
where |
Deprecated. Use |
verbose |
A boolean indicating whether to print the constructed query |
... |
Arguments to create the WHERE statement or as in the case of
the |
ll |
A list object that wraps the R expressions in order to translate to sql where conditions |
string |
A string to concat to the supplied where statement |
x |
A logical operation in the form of an expression |
FILL IN DETAIL HERE. See example workflows
QuerySauce
: A function to build the query
WhereSauce
: A function to the WHERE clause that becomes an input into
QuerySauce
OpsDT
: Function to translate R operators to sql ones
QueryTree
: Function to build query
ColSauce
: A function to retrieve the column names associated with the
expressions given in the WhereSauce args
AND
: A helper to append arbitrary AND conditions to the return object of Wsauce
. See examples
OR
: A helper to append arbitrary OR conditions to the return object of Wsauce
. See examples
not
: A function to handle not expressions
Qsauce
: An alias to QuerySauce
Wsauce
: An alias to WhereSauce
op
: Get operator
ch_op
: Get character op
lop
: Get left side op
clop
: Get character left side op
rop
: Get right side op
crop
: Get character right side op
revop
: Reverse operations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Not run:
# STEP 1: Name the configured database
# STEP 2: Name the table to query
# STEP 3: Get the WHERE sauce (optional ingredient for the query sauce)
# STEP 4: Get the Query sauce (main ingredient for the data dish)
#----------------------------------------------------------------------------
db <- "RemoteFE"
tbl <- "SFDC.dbo.PROCEDURES"
#----------------------------------------------------------------------------
# Get procedures of specified subjects that occurred since 2015
#----------------------------------------------------------------------------
psub <- c("HPB", "dVP", "dVC", "dVL") # for WHERE sauce
wh <- WhereSauce(ProcedureSubject == psub & Year(CreateDate) > 2015)
query <- QuerySauce(tbl, top = 1000, where = wh)
DT <- xQuery(db, query)
#----------------------------------------------------------------------------
# Alternate workflow:
# Open/Closing is handled by xQuery unless db is open. In which case,
# the user can control when to open and close connections
#----------------------------------------------------------------------------
OpenDB(db) # Open connection
# .... Do work
CloseDB(db) # Close connection
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.