ODBC_SQL Function
Initiate an SQL command.
Usage
table = ODBC_SQL(connect_handle, sql_stmt)
Input Parameters
connect_handle—The handle returned by ODBC_CONNECT.
sql_stmt—A string containing an SQL statement to execute on the data source.
Returned Value
table—A PV‑WAVE table containing the result of the SQL commands, table data, or other data source response data. If the function fails or if no data is available, –1 is returned.
Keywords
Null_Info—Returns an associative array containing information on nulls in the database query result.
Discussion
For detailed information on working with tables in PV‑WAVE, see the PV‑WAVE User’s Guide.
Example 1
This example imports all of the data from the emp table.
emp = ODBC_SQL(oracle_id, 'SELECT * from emp')
Example 2
This example imports the name, job, and salary of the managers whose salary is greater than $2800.
emp = ODBC_SQL(oracle_id, "SELECT ename, job," + $
"sal from emp where job = 'MANAGER' and " + "SAL > 2800")
Example 3
This example imports the names and salaries of employees whose salary is between $1200 and $1400.
emp = ODBC_SQL(oracle_id, 'SELECT ename, sal' + $
'from emp where sal between 1200 and 1400')
Example 4
This example imports the names of employees and their commissions whenever the commission is not a NULL value.
table = ODBC_SQL(oracle_id, 'SELECT ename' +$
'from emp where comm is not NULL')
Example 5
This example uses the Null_Info keyword.
Table=odbc_sql(hcon,'select * from blanktest',null_info=foo)
This returns the result ‘table’ from your query and the null info object associative array ‘foo’. Foo contains three elements:
N_ROWS = the number of rows returned in the query
N_COLS = the number of columns or fields returned
MISSING_DATA = the null info object associative array
MISSING_DATA associative array contains field name tags, each of which has the associated array listing the rows with missing data for the tag.
For more information on the null info object and to process and extract the null information array use the NULL_PROCESSOR function.
See Also
See the following related functions in the PV-WAVE Reference:
BUILD_TABLE, GROUP_BY, ORDER_BY, QUERY_TABLE, UNIQUE