SQLExec(), SQLPrepare()
The "exec" here stands for "execute". SQLExec() sends commands to the server to be executed. SQLPrepare() lets you speed up that execution by compiling the command before it's executed. You send it on ahead to the server, which compiles it and keeps it ready to go.
Usage |
nSuccess = SQLExec( nConnectionHandle [, cCommand [, cResultCursor ] ) nSuccess = SQLPrepare( nConnectionHandle, cCommand [, cResultCursor ] ) |
Parameter |
Value |
Meaning |
nConnectionHandle |
Numeric |
The existing connection handle for the remote database being queried. |
cCommand |
Character |
The command or commands to pass to the server. |
Omitted |
Execute a command previously passed to the server with SQLPrepare(). |
|
cResultCursor |
Character |
The name of a cursor in which to store the results of cCommand. |
Omitted |
Name the result cursor SQLResult. |
|
nSuccess |
Positive |
The number of result sets returned. |
0 |
Still executing commands. |
|
-1 |
An error occurred. |
Example |
* In synchronous mode nHandle = SQLConnect("Northwinds") IF nHandle > 0 IF SQLExec(nHandle, "Select * FROM Customers") = 1 BROWSE ELSE WAIT WINDOW "Trouble at the pass" ENDIF ELSE WAIT WINDOW "Can't connect" ENDIF * Set up a parameterized SPT command * Use the same connection as above cCountry = "" IF SQLPrepare(nHandle, ; "SELECT * FROM Customers WHERE Country = ?cCountry") = 1 cCountry = "UK" IF SQLExec(nHandle) = 1 * Got all UK Customers BROWSE TITLE "Customers in the UK" ENDIF cCountry = "USA" IF SQLExec(nHandle) = 1 * Got all US Customers BROWSE TITLE "Customers in the USA" ENDIF ENDIF |
See Also |
SQLCancel(), SQLConnect(), SQLDisconnect(), SQLGetProp(), SQLMoreResults(), SQLSetProp() |