Description Usage Arguments Value Queries and Views Note Author(s) Examples
View source: R/odb.queries_GET.r
This function allows stored SQL queries manipulation into OpenOffice Base databases, through an odb
connection.
1 2 | odb.queries(odb, queryNames = NULL)
odb.queries(odb, queryNames) <- value
|
odb |
An |
queryNames |
Character vector naming queries to get or set. |
value |
Character vector, containing the SQL queries to store. |
Returns a named character vector of SQL queries.
These functions manipulate OpenOffice queries, which are stored in the .odb file and not the database itself. They should not be confused with views, which are SQL features handled by the database engine.
Views are more portable (as they are stored in the database), and can be accessed as virtual tables in SQL queries. To manage them, user is required to use the SQL queries "CREATE VIEW" and "DROP VIEW" (with the odb.write
in this package context). More informations on these SQL queries can be found in the HSQL documentation.
The user is required to check and keep its queries up-to-date himself.
Queries can also be manipulated manually from OpenOffice.
Sylvain Mareschal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # New empty .odb file
odbFile <- tempfile(fileext=".odb")
odb.create(odbFile, overwrite="do")
odb <- odb.open(odbFile)
# New table
odb.write(odb, "CREATE TABLE fruits (name VARCHAR(6) PRIMARY KEY)")
odb.insert(odb, "fruits", c("banana", "pear", "peach"))
# Single query
odb.queries(odb, "banana") = "SELECT * FROM fruits WHERE name='banana'"
print(odb.read(odb, odb.queries(odb, "banana")))
# Multiple queries
odb.queries(odb, c("banana","pear")) <- c(
"SELECT * FROM fruits WHERE name='banana'",
"SELECT * FROM fruits WHERE name='pear'"
)
# All queries
print(odb.queries(odb))
# Writes to the file and closes the connection
odb.close(odb, write=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.