共用方式為


SQLPREPARE( ) Function

Prepares a SQL statement for remote execution by SQLEXEC( ).

SQLPREPARE(nConnectionHandle, cSQLCommand, [cCursorName])

Return Values

Numeric

Parameters

  • nConnectionHandle
    Specifies the connection handle to the data source returned by SQLCONNECT( ).

  • cSQLCommand
    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.

    For additional information about creating parameterized views, see Creating Views.

  • 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.

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 connection handle is required in SQLEXEC( ).

Example

gcAuthor = 'Smith'
= SQLPREPARE(gnConnHandle, 'SELECT * FROM authors;   WHERE au_lname = ?gcAuthor')
= SQLEXEC(gnConnHandle)

...

gcAuthor = 'Jones'
= SQLEXEC(gnConnHandle)

See Also

SQLCONNECT( ) | SQLEXEC( ) | Creating Views