Learn R Programming

ROracle (version 0.3-3)

metaData: R/S database interface meta-data

Description

Extract meta-data associated with various objects

Usage

getInfo(obj, what)      # meta-data for any dbObject
getConnection(what, ...)

getConnections(mgr) # meta-data for dbManager objects getDatabases(obj, ...) getTables(obj, dbname, ...) getVersion(obj, ...) getTableIndices(res, table, dbname, ...)

getCurrentDatabase(con) # meta-data for dbConnection objects getException(con, ...) getResultSets(con, ...) getTableFields(res, table, dbname, ...)

getStatement(res) # meta-data for dbResultSet objects getFields(res, ...) hasCompleted(res, ...) getRowCount(res, ...) getRowsAffected(res, ...) getNullOk(res, ...)

Arguments

obj
any object that implements some functionality in the R/S interface to databases (e.g., dbManager, dbConnection, dbResultSet).
what
a character vector identifying the piece of meta-data to extract, e.g., "statement" in the case of a dbResultSet object or "dbname" for a dbConnection object.
mgr
refers to a dbManager object.
con
refers to a dbConnection object.
res
refers to a dbResultSet object.
dbname
refers to a database name (instance) on the server.
table
refers to a table name in either the current database or in dbname.
...
any other parameters are passed to the actual methods.

Value

  • either a character vector or a named list of meta-data objects.

References

See the Omega Project for Statistical Computing at http://www.omegahat.org for more details on the R/S database interface.

Details

These functions implement a minimal set of more or less obvious meta-data describing the most important aspects of the R/S to RDBMS interface.

The getInfo works very similarly to the function options in that it attempts to extract what the user may request, possibly NULL if it can't locate the specific piece of meta-data.

See Also

On database managers:

dbManager Oracle load unload

On connections, SQL statements and resultSets:

dbExecStatement dbExec fetch quickSQL

On transaction management:

commit rollback

On meta-data:

describe getVersion getDatabases getTables getFields getCurrentDatabase getTableIndices getException getStatement hasCompleted getRowCount getAffectedRows getNullOk getInfo

Examples

Run this code
m <- dbManager(dbms)

# Extract meta-data information.  What MySQL databases are there 
# available on host "wyner"

> getDatabases(m, host = "wyner")
   Database 
1     mysql
2      opto
3      test
4 iptraffic
5     fraud

# What tables are there in the Oracle "opto" database? 

> dbTables(m, dbname = "opto", host = "wyner")
  Tables in opto 
1           PBCT
2          PURGE
3             WL
4          liv25
5          liv85

# let's look at some result set meta-data

> con <- dbConnect(m)
> rs <- dbExecStatement(con, query.sql)

> getStatement(rs)
[1] "show tables"

> hasCompleted(rs)
[1] 0

> getRowCount(rs)
[1] 3

> info <- getInfo(rs)
> names(info)
[1] "statement"     "isSelect"        "rowsAffected"     
[4] "rowCount"     "completed"    "fieldDescription"
> getStatement(rs)
[1] "show tables"

# the following are pieces of meta-data associated with 
# the R/S DBI implementation, versions for the various pieces 
# of software (client, server, interface), etc.

# dbManager object

> names(getInfo(m))  
[1] "connectionIds"     "fetch_default_rec"
[3] "managerId"         "length"           
[5] "num_con"           "counter"          
[7] "clientVersion"    

#  dbConnection object

> names(getInfo(con))
[1] "host"            "user"           
[3] "dbname"          "conType"        
[5] "serverVersion"   "protocolVersion"
[7] "threadId"        "rsId"           

# resultSet object

> names(getInfo(rs)) 
[1] "statement"        "isSelect"        
[3] "rowsAffected"     "rowCount"        
[5] "completed"        "fieldDescription"

Run the code above in your browser using DataLab