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).
hsSqlExOr(x, bFunc = "")
x | vector of strings, e.g. representing table field names. |
---|---|
bFunc | name of a boolean function to be “applied” to each element of x. |
## 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#> [1] "SELECT * FROM t WHERE (FALSE) OR isNull(f1) OR isNull(f2) OR isNull(f3) OR isNull(f4) OR isNull(f5) OR isNull(f6) OR isNull(f7) OR isNull(f8) OR isNull(f9) OR isNull(f10) OR isNull(f11) OR isNull(f12) OR isNull(f13) OR isNull(f14) OR isNull(f15) OR isNull(f16) OR isNull(f17) OR isNull(f18) OR isNull(f19) OR isNull(f20) OR isNull(f21) OR isNull(f22) OR isNull(f23) OR isNull(f24) OR isNull(f25) OR isNull(f26) OR isNull(f27) OR isNull(f28) OR isNull(f29) OR isNull(f30) OR isNull(f31) OR isNull(f32) OR isNull(f33) OR isNull(f34) OR isNull(f35) OR isNull(f36) OR isNull(f37) OR isNull(f38) OR isNull(f39) OR isNull(f40) OR isNull(f41) OR isNull(f42) OR isNull(f43) OR isNull(f44) OR isNull(f45) OR isNull(f46) OR isNull(f47) OR isNull(f48) OR isNull(f49) OR isNull(f50) OR isNull(f51) OR isNull(f52) OR isNull(f53) OR isNull(f54) OR isNull(f55) OR isNull(f56) OR isNull(f57) OR isNull(f58) OR isNull(f59) OR isNull(f60) OR isNull(f61) OR isNull(f62) OR isNull(f63) OR isNull(f64) OR isNull(f65) OR isNull(f66) OR isNull(f67) OR isNull(f68) OR isNull(f69) OR isNull(f70) OR isNull(f71) OR isNull(f72) OR isNull(f73) OR isNull(f74) OR isNull(f75) OR isNull(f76) OR isNull(f77) OR isNull(f78) OR isNull(f79) OR isNull(f80) OR isNull(f81) OR isNull(f82) OR isNull(f83) OR isNull(f84) OR isNull(f85) OR isNull(f86) OR isNull(f87) OR isNull(f88) OR isNull(f89) OR isNull(f90) OR isNull(f91) OR isNull(f92) OR isNull(f93) OR isNull(f94) OR isNull(f95) OR isNull(f96) OR isNull(f97) OR isNull(f98) OR isNull(f99) OR isNull(f100)"## Output (middle part omitted): # SELECT * FROM t WHERE (FALSE) OR isNull(f1) OR # isNull(f2) OR isNull(f3) OR ... OR isNull(f100)