idaQuery: Run an SQL query on the database

idaQuery, idaScalarQueryR Documentation

Run an SQL query on the database

Description

Use these functions to run any SQL query on the database and put the results into a data.frame.

Usage

idaQuery(..., as.is=TRUE, na.strings = "NA")

idaScalarQuery(..., as.is=TRUE)

Arguments

...

Any number of query parts which are passed to paste.

as.is

Specifies whether the result columns are to be converted using RODBC type conversions (as.is=FALSE) or left unconverted (as.is=TRUE). For more information about RODBC type conversions, see the descriptions of the functions sqlGetResults and type.convert.

na.strings

character vector of strings to be mapped to NA when reading character data.

Details

All parts of the input query are concatenated with paste(..., sep="") and the result is passed to the database.

Value

The idaQuery function returns a data frame that contains the result of the specified query.

The idaScalarQuery function returns the result of the specified query coerced to a single scalar value.

Examples

## Not run: 
#idaScalarQuery returns a single value
v <- idaScalarQuery("SELECT COUNT(*) FROM IRIS")

#idaQuery returns a data.frame
df <- idaQuery("SELECT * FROM IRIS")

#idaQuery and idaScalarQuery automatically paste all arguments into a single query
#This is convenient if you use variables

tableName <- "IRIS"
df <- idaScalarQuery("SELECT COUNT(*) FROM ",tableName)

## End(Not run)

ibmdbR documentation built on Nov. 24, 2023, 5:09 p.m.