F.sql.error.check: F.sql.error.check

F.sql.error.checkR Documentation

F.sql.error.check

Description

Check if a SQL statement executed correctly.

Usage

F.sql.error.check(obj)

Arguments

obj

The results from an Access query. See Details.

Details

Function F.sql_error_check is used immediately after the use of RODBC function sqlQuery, which queries an Access database via a text string formatted as a SQL query. Function sqlQuery, if successful, results in a dataframe, possibly with zero rows. Otherwise, a character vector with error messsages is returned. Function F.sql.error.check examines if an error message is returned, and if found, stops execution and prints an error message to the R_run.out text file or the R Console.

Value

FALSE, assuming successful completion of a SQL query. Otherwise, an error message to either the Console window, if running directly via R, or to the run_R.out file, if running via the Platform.

Author(s)

WEST Inc.

See Also

sqlQuery

Examples

## Not run: 
#   ---- Set up an Access mdb in R.  
db.file <- "C:/yourPath/CAMP.mdb"                # The location of CAMP.mdb
db <- get( "db.file", envir=.GlobalEnv )           # Assign the mdb string.
ch <- odbcConnectAccess(db)                      # Connect R and Access.

#   ---- Conduct a good query.
ans <- sqlQuery( ch, "SELECT * FROM luRun" )     # Select all rows.
F.sql.error.check(ans)                           # Check for validity.  
                                                 #  --> Results in FALSE.

#   ---- Conduct a bad query.
ans <- sqlQuery( ch, "SELECT * FROM fakeTable" ) # Select all rows.
F.sql.error.check(ans)                           # Check for validity.  
                                                 #  --> Results in error message.  

## End(Not run)

tmcd82070/CAMP_RST documentation built on April 6, 2022, 12:07 a.m.