get_anything_sql: Extract anything from obDBS

Description Usage Arguments Value Warning Reference See Also Examples

View source: R/get_anything_sql.R

Description

Extract any information from any database. This function is for people who know sql and understand the database well enough to write their own sql statements. For all others, please use other functions in package

Usage

1
get_anything_sql(channel, sqlStatement)

Arguments

channel

an RODBC object (see connect_to_database)

sqlStatement

an sql statement

Value

A list is returned:

- data containing the result of the executed sqlStatement and

- sql containing the sqlStatement itself

- colNames a vector of the table's column names

There is no default sql statement.

Warning

You will need to obtain read only privilages to access any of the databases Some of the databases contains many million records. If you try to pull the entire database it is likely you will run out of memory.

Reference

Use the data dictionary (http://nova.nefsc.noaa.gov/datadict/) for field name explanations

See Also

connect_to_database

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 

# extracts silver hake (072) in area stratum (01010) for year 2001
channel <- connect_to_database(server="name_of_server",uid="individuals_username")

sqlStatement <- "select cruise6, stratum, tow, station, length, indwt,sex from svdbs.union_fscs_svbio
 where  (svspp in 72)  and (stratum in 01010) and (cruise6 like '2001%');"

get_anything_sql(channel,sqlStatement)

## End(Not run)

andybeet/obdbs documentation built on Feb. 5, 2021, 9:24 p.m.