Highlighted
Absent Member.
Absent Member.
300 views

SQL Cursor

Jump to solution

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?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.
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

View solution in original post

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.
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

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.