ODBC_PREPARE Function
Sets up a cursor for use with ODBC_FETCH.
Restriction: See "Supported Platforms Guide" on the PV-WAVE Documentation website to check if this function is available on your operating system.
Usage
stmt = ODBC_PREPARE(connect_handle, sql_command, cursor_size)
Input Parameters
connect_handle—The handle returned by ODBC_CONNECT.
sql_command—A string containing SQL statement(s) to execute on a data source.
cursor_size—An integer specifying the number of rows to fetch for each call to ODBC_FETCH. If this parameter is missing, cursor_size defaults to the value specified by the system variable !Odbc_Rowset_Size.
Returned Value
stmt—The ID for the SQL statement. This ID is used as input to the function ODBC_FETCH.
Discussion
ODBC_PREPARE is used to prepare the result set on the DBMS server, so that it can be imported into a PV‑WAVE table with ODBC_FETCH.
While ODBC_SQL is used to return an entire result set, ODBC_PREPARE and ODBC_FETCH allow you to control the rate at which data is imported. Each call to ODBC_FETCH will return at most the number of rows specified by the cursor size.
Although the default cursor size is the same as the value in the system variable !Odbc_Rowset_Size, specifying the cursor size as a parameter does not change the value of !Odbc_Rowset_Size. For more information on changing the rowset size, see Controlling the Rowset Size .
Once a result set has been created with ODBC_PREPARE, the cursor size cannot be changed until another call is made to ODBC_PREPARE, which creates a new result set.
Example
orders_select = ODBC_PREPARE(dbase_orders, $
'SELECT * FROM [orders];', 15)