SqlPrepare Function | |
Prepares a SQL statement for remote execution by SqlExec( ).
Namespace:
XSharp.VFP
Assembly:
XSharp.VFP (in XSharp.VFP.dll) Version: 2.21
Syntax [NeedsAccessToLocalsAttribute(TRUE)]
FUNCTION SqlPrepare(
nStatementHandle AS LONG,
cSQLCommand AS STRING,
cCursorName AS STRING
) AS LONG
[NeedsAccessToLocalsAttribute(true)]
public static int SqlPrepare(
int nStatementHandle,
string cSQLCommand,
[DefaultParameterValueAttribute("SQLRESULT", 0)] string cCursorName
)
Request Example
View SourceParameters
- nStatementHandle
- Type: Long
Specifies the statement handle to the data source returned by SqlConnect( ).
- cSQLCommand
- Type: String
Specifies the SQL statement passed to the data source.
The SQL statement can contain a parameterized Where clause, which creates a parameterized view. All parameters in the Where clause must be defined before
SqlPrepare( ) is issued. For example, if the parameters are variables, the variables must be created and initialized before SqlPrepare( ) is issued.
Tip |
---|
Parameterized queries are not yet supported in X# |
- cCursorName
- Type: String
Specifies the name of the X# cursor to which the result set is sent. If you don't include a cursor name, X# 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.
Return Value
Type:
Long
Numeric
Remarks
SqlPrepare( ) sends the SQL statement to the data source where it is compiled for faster execution. After the SQL statement is compiled,
it can be executed with SqlExec( ). If SqlExec( ) is used to execute a SQL statement prepared with SqlPrepare( ),
only the statement handle is required in SqlExec( ).
Examples 1gcAuthor = 'Smith'
2= SqlPrepare(gnHandle, 'Select * From authors; Where au_lname = ?gcAuthor')
3= SqlExec(gnHandle)
4...
5gcAuthor = 'Jones'
6= SqlExec(gnHandle)
See Also