tdMakeSQL: tdMakeSQL

Description Usage Arguments Details Value See Also Examples

Description

Takes a SQL file and replaces pointers with user declared values. Can take a JDBC connection object (conn) if provided. If no JDBC connection is provided, then a connection is attempted using the user, and password provided. If none is provided, then tries to locate a connection object (conn) in the global environment.

If a connection profile (e.g. username, password, etc.) is provided, then an attempt is made to connect to Teradata. Once the query is run, the connection is then closed. If a connection object (conn) is provided to the function (or one is found globally), then the connection remains open.

Usage

1
tdMakeSQL(file = NULL, outfile = NULL, ...)

Arguments

file

File to submit to Teradata.

outfile

Optional file name to output code to. If supplied, then code will be printed in file rather than console.

...

Optional arguments to replace pointers.

Details

Warning: This function reads in all lines and parses commands using ";". Thus, commands should be separated using that character. If a literal ";" is desired within the code, an escape character of "\" should precede it, e.g. where column="\;". Pointers should be saved in the file using a "&" prefix. An escape character of "\" can also be used for this if a literal "&" is desired within the code.

Value

A string vector is returned of the SQL code.

See Also

tdConn for connection, tdHead for top observations, tdSpool for spool usage, and td for general queries

Examples

1
2
3
4
5
6
7
8
9
## NOT RUN ##
## Simply returns the code from the file
# tdMakeSQL("file.sql")

## Returns code from file, replacing "&ABTExt" with "Test"
# tdMakeSQL("file.sql", ABTExt="Test")

## Returns code from file, replacing "&ABTExt" with "Test" and "&baseExt" with "ing"
# tdMakeSQL("file.sql", ABTExt="Test", baseExt="ing")

tranlm/tdR documentation built on May 31, 2019, 7:45 p.m.