Menu

Create cursor with adOpenForwardOnly

OTL
2017-11-28
2017-11-28
  • Jose Antonio Castelbón

    Hello,
    There is a way to create cursors on ADO specifying a parameter, cursor type. A valid value for this parameter is adForwardOnly.

    https://docs.microsoft.com/en-us/sql/ado/guide/data/forward-only-cursors

    With this parameter active ADO cursors are faster than otl cursors, i've been looking the online help, but i cannot find something like this on otl_stream class.

    ¿Is there a way on otl for create ADO-style forward-only cursors?
    Sorry for my bad english and thanks in advance.
    Jose

     

    Last edit: Jose Antonio Castelbón 2017-11-28
  • Sergei Kuchin

    Sergei Kuchin - 2017-11-28

    Jose,

    OTL supports different ODBC/DB2-CLI cursor types. Here's an excerpt from the manual (http://otl.sourceforge.net/otl3_connect_class.htm):

    void set_cursor_type
    (const int acursor_type=0);

    This function works in OTL 4.0/ODBC and OTL 4.0/DB2-CLI only, and it has not effect in OTL 4.0/OCIx. Sets the cursor type. Once the cursor type is set, the setting will be propagated to all SELECT statements opened via the otl_stream class in the current connect object.
    

    The following cursor types are available (for more detail, see the ODBC Programmer's Guide, or the DB2 CLI Programmer's Guide):

    SQL_CURSOR_FORWARD_ONLY (default setting)
    SQL_CURSOR_STATIC
    SQL_CURSOR_KEYSET_DRIVEN
    SQL_CURSOR_DYNAMIC
    

    However, you're not going to get any speedup from using "forward only" cursors. The difference is due to ADO (which is OLE DB based) vs ODBC. OTL is ODBC based. ODBC compared with OLE DB is based on a more expensive / slower protocol, but at least Microsoft ported their ODBC driver for SQL Server to Linux. If you have any further questions, email me at skuchin@gmail.com

    Cheers,
    Sergei

     

Log in to post a comment.