Skip to Main Content

Programming Languages & Frameworks

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to return row count with the data in the resultset

GadoDec 21 2022

Hello,
I am building an app using React, Node/Express and Oracle 19c.
To connect with database I am using node_oracledb v5.3.0
I am able to fetch data from database table and return it to the frontend as a Json object. But now I am trying to use pagination in the frontend. To do that I need to also have the total number of rows in the table along with the subset (page) of the data itself.
I know that I can add count(*) to the query but this will return the count in every row. What I am looking for is something like this:

{
  info: {
         totalRows: 1000
        },
  data: [
          {row1} , {row2} , ...
        ]
}

I hope this is clear enough.

Thanks,
Gado

Comments

Post Details

Added on Dec 21 2022
1 comment
1,048 views