• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Oracle: Paginating LISTAGG()

Resolved: Oracle: Paginating LISTAGG()

0
By Isaac Tonny on 04/04/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve Oracle: Paginating LISTAGG()

Question:

I am trying to pull a set of quoted UUIDs from a database, and am using LISTAGG() to do so, thus:
This works perfectly well, but there are some use-cases where the number of UUIDs presented creates a string that is too long (hence the usage of ON OVERFLOW ERROR). In these cases, I would like to iterate LISTAGG() over batches of returned results. I feel like I am on the right track with something like this:
But I don’t want to have to manually increment the OFFSET until I run out of records. Ideally I would be able to in one shot get an aggregated list in batches of all of the returned records. Is this doable?
(My access to this DB is limited; I cannot CREATE views, temporary tables, functions, or any of that fun stuff for Reasons).

Best Answer:

Use GROUP BY CEIL(ROWNUM/99) to “paginate” the UUIDs into groups of 99 rows and then aggregate those rows. Additional “pages” will be in the next group(s) so you will get multiple rows:
fiddle

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

listagg oracle sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to stop a thread that has a blocking function from easygui in python

05/04/2023

Resolved: Removing null keys from a json array of objects

05/04/2023

Resolved: How can I generate at compile-time a separate OpenAPI Swagger.json file for each Controller in my ASP.NET project?

05/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.