hsSqlExOr: SQL Expression "OR"

View source: R/sql_expressions.R

hsSqlExOrR Documentation

SQL Expression “OR”

Description

Creates a boolean expression of the form
bFunc(x1) OR bFunc(x2) OR ... OR bFunc(xn). This function can be used to create SQL queries where many table fields have to be checked in the same way for some criterion (see example).

Usage

hsSqlExOr(x, bFunc = "")

Arguments

x

vector of strings, e.g. representing table field names.

bFunc

name of a boolean function to be “applied” to each element of x.

See Also

hsSqlExAnd

Examples

## Build SQL query finding records in table t in which at least
## one of the table fields f1 to f100 is NULL.
sql <- sprintf("SELECT * FROM t WHERE %s", 
               hsSqlExOr(paste("f", 1:100, sep = ""), "isNull"))
  
## Show the SQL string
sql
  
## Output (middle part omitted):
# SELECT * FROM t WHERE (FALSE) OR isNull(f1) OR 
# isNull(f2) OR isNull(f3) OR ... OR isNull(f100)


KWB-R/kwb.db documentation built on Oct. 1, 2023, 4:10 a.m.