Contents Previous Next sqlexec

Executing a Query Statement
Syntax sqlexec(query statement)
See Also sqlconnect , sqlfetch

Description
Executes query statement against the database specified in the last call to sqlconnect. The argument query statement must be a character row vector that represents a valid SQL statement. The sqlexec function passes the given query statement to the data source that has been connected in the most recent call to sqlconnect. If successful, the sqlexec function creates a result set which may be retrieved into O-Matrix using the sqlfetch function.

The sqlexec function will support all queries that generate numeric or text valued result sets but does not support queries that generate result sets that contain binary objects such as images.

Examples
The following example performs a simple query against, and returns results from the Contacts sample database provided with the Data Access Toolbox. If at the O-Matrix prompt you enter
     sqlconnect("driver={Microsoft Access Driver (*.mdb)};Dbq=c:\omwin\omsql\Contacts.mdb;UID=;PWD=")
     sqlexec("SELECT CompanyID, CompanyName FROM Company ORDER BY City")
     sqlfetch
O-Matrix will respond

4         Northwind Traders
3         Health Food Store
2         Fourth Coffee
1         Cascade Coffee Roasters
5         Volcano Coffee Company