SQLEXEC( ) Function

Sends a SQL statement to the data source, where the statement is processed.

SQLEXEC(nStatementHandle [, cSQLCommand [, cCursorName[, aCountInfo]]])

Parameters

nStatementHandle

Specifies the statement handle to the data source returned by the SQLCONNECT( ) function. For more information, see SQLCONNECT( ) Function.

cSQLCommand

Specifies the SQL statement passed to the data source.

The SQL statement can contain a parameterized WHERE clause, which creates a parameterized view. You must define all parameters in the WHERE clause before issuing SQLEXEC( ). For example, if the parameters are variables, the variables must be created and initialized before SQLEXEC( ) is issued. For more information about parameterized views, see How to: Create Parameterized Views.

You can include expressions in the SQL statement. Visual FoxPro evaluates all expressions in the SQL statement that you pass before sending them to the data source. Visual FoxPro can evaluate memory variable names, function calls, and expressions enclosed in parentheses as parameter values.

cCursorName

Specifies the name of the Visual FoxPro cursor to which the result set is sent. If you don't include a cursor name, Visual FoxPro uses the default name SQLRESULT.

For multiple result sets, new cursor names are derived by appending an incremented number to the name of the first cursor.

aCountInfo

Specifies the name of the array to populate with row count information. If the array doesn’t exist, it is created. The array has two columns: 1 – Alias, 2 –Count.

Column Array contents Data type Description

Alias

0

Character

Indicates that SQL command did not return any results. Either no records were returned or the SQL command failed before results could be returned. (final SQLMORERESULTS call) or execution failed before any result could be processed. Can be only on the first row. Count column for the row contains value -1.

Non-empty uppercase string

Character

Alias of the cursor – target for the record fetch operation. The Count column for the row contains the number of fetched records or -1 if fetch failed. If Count is -1, cursor may not have been created. During asynchronous execution, the fetch process for a cursor can be split between multiple SQLMORERESULTS or SQLEXEC calls; each call returns its own fetch count for the cursor.

Empty String

Character

Indicates that the SQL command (INSERT, UPDATE, or DELETE) did not return a result set.

Count

Number of affected or fetched records.

Integer

Indicates the number of affected records as returned by the ODBC SQLRowCount function. Returns -1 if the number of records is unavailable.

Expand imageReturn Value

Expand imageRemarks

Expand imageExample

Expand imageSee Also


© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic