Execute queries {RPgSQL}R Documentation

Send commands to the PostgreSQL back end

Description

db.execute sends a query to the database back end for processing. db.result.status returns a result code indicating the status of the result buffer.
db.clear.result frees the result buffer.
db.toggle.echo toggles between echo'ing all communication with the back end.

Usage

db.execute(..., clear=T, report.errors=T)
db.result.status()
db.clear.result()
db.toggle.echo()

Arguments

... A character string containing any valid command or query to be sent to the PostgreSQL back end.
clear If true, free any resources allocated by db.execute() immediately on returning.
report.errors If true, report fatal and non-fatal errors

Details

See the file "libpq-fe.h" in your PostgreSQL distribution for a listing of error codes.

Author(s)

Timothy H. Keitt

See Also

db.result.get.value

Examples

if (db.connection.open()) {
  db.execute("select * from pg_user", clear=F)
  db.result.status()
  for (i in 1:db.result.rows()) cat(db.result.get.value(row=i), "\n")
  db.clear.result()
}