Skip to content

No data results hides subsequent result sets. #43

@lexicalunit

Description

@lexicalunit

From @aquasync on December 30, 2014 0:48

I'm using nanodbc to run a chunk of sql containing multiple statements (dml/ddl along with selects), and iterating through the results with something like the following:

nanodbc::connection db("...");
nanodbc::result res = execute(db, sql);
do {
    if (bool(res) && res.columns() > 0) {
        // process resultset
    }
} while (bool(res) && res.next_result());

I ran into the situation where queries which return no data return a default-constructed result object, as the SQL_NO_DATA path in execute/execute_direct is taken. This causes it to have no underlying result_impl or reference to the statement, so you are unable to advance to subsequent result sets. Adding a preceding dummy query seems to fix this.

For example, in "select top 0 1 as a into #temp; select 2 as b", data from the latter select is not reachable, but prepending "select 1 as a into #dummy; " returns a valid result object allowing you to iterate to the final result set.

Commenting out the above-mentioned SQL_NO_DATA path in both execute & execute_direct fixes this for me by returning a valid result object always. Could this be deleted upstream or is it needed in some other situtation?

Copied from original issue: lexicalunit/nanodbc#33

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions