Skip to content

Fetch multiple rows #977

Open
Open
@rodrigolive

Description

Using the ODBC (node-odbc) driver I'm able to fetch more than one row at a time with stmt.fetch() using fetchSize from a DB2 iAccess Connect driver. How can I accomplish the same with node-ibm_db directly, without using the ODBC driver?

This is the ODBC driver code I'm looking to reproduce directly using the ibm_db driver:

const cursor = await db.query(sql, params, {
     cursor: true,
     fetchSize: 1000
});

let rows = await cursor.fetch();  //  fetches 1000 rows
rows = await cursor.fetch();  //  fetches next 1000 rows
// ... until cursor.noData === true

The motivation is that fetchAll() is unusable for large tables and stmt.fetch() for single rows is excruciatingly slow for large tables (ie. 20M rows). It makes the driver unusable for real-world situations for dealing with large table processing. This feature is available for the JDBC DB2 driver equivalent OTOH.

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