SQL Cursor

I have a question about using cursors with ADO and ODBC.

 

Currently I am using ADO to get the result of a query in a datareader object:

 

01 DATAREADER-9615 TYPE System.Data.SqlClient.SqlDataReader.

 

EXEC ADO

GET CURSOR CURSOR_9615 INTO :DATAREADER-9615

END-EXEC.

 

But, what if i wanted to ODBC. So:

 

01 DATAREADER-9615 TYPE System.Data.Odbc.OdbcDataReader.

 

Which EXEC SQL statement do I have to use to get the result in my datareader object?

  • Verified Answer

    Hi Mark,
    The same approach ( EXEC ADO GET CURSOR) should work for all ADO providers, ie Oracle, PostgreSQL, DB2. For ODBC you'd just set up a data source using the ODBC managed provider which hooks up an ODBC data source via ADO. For each provider you will get a different ADO data reader class, as you have already noticed.

    Having said this, I'd caution against using the ODBC Managed Provider at all unless there is no practical alternative. The ODBC provider was written in the early days of ADO with the intention of getting a lot of existing data sources onboard with ADO quickly. It's performance is not stellar and it doesn't get a lot of support from Microsoft. Most data sources have good quality ADO providers nowadays, and this should always be your first choice wherever practicable.

    Hope this helps,

    Chris Lee