PS Query & SQL

 View Only
  • 1.  ListAgg Expression Help

    Posted 03-18-2026 09:05 PM

    I'm working on a query to identify a list of courses in the course catalog with a GE course attribute (CRSE_ATTR). I created a LISTAGG expression to list the Course Attribute Value (CRSE_ATTR_VALUE) all on one row instead of multiple rows, but I am getting a CLOB error message. Here is my expression: 

    What am I missing in this expression?

    Max



    ------------------------------
    Pheng Xiong Ph.D.
    Senior Associate Registrar
    Rochester Institute of Technology
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------
    Alliance 2026 Recordings are here!


  • 2.  RE: ListAgg Expression Help

    Posted 03-19-2026 04:01 AM

    Without seeing the full SQL I am guessing a bit. It does look like you have an extra bracket in that expression (after LISTAGG)

    This SQL works for me.

    select a.crse_id, listagg(a.crse_attr_value,',') within group (order by a.crse_attr_value) as attr_values
    from ps_crse_attributes a
    where a.effdt = (select max(effdt) from ps_crse_attributes a_ed
                     where a_ed.crse_id=a.crse_id
                     and a_ed.effdt<=SYSDATE)
    and a.crse_attr='EAA'
    group by a.crse_id

    order by 1



    ------------------------------
    Daron Wild
    Senior PeopleSoft Developer
    University of Cambridge
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------

    Alliance 2026 Recordings are here!


  • 3.  RE: ListAgg Expression Help

    Posted 03-19-2026 05:13 AM

    Actually, the brackets are fine.  Seeing Normalungelo's reply, I did quickly build a PSQuery using my SQL.

    It did run okay. Maybe post your full SQL from PSQuery to see if something else is in there causing your error.



    ------------------------------
    Daron Wild
    Senior PeopleSoft Developer
    University of Cambridge
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------

    Alliance 2026 Recordings are here!


  • 4.  RE: ListAgg Expression Help

    Posted 03-19-2026 07:42 AM

    Hi Daron,

    Here is my full SQL: 



    ------------------------------
    Pheng Xiong Ph.D.
    Senior Associate Registrar
    Rochester Institute of Technology
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------

    Alliance 2026 Recordings are here!


  • 5.  RE: ListAgg Expression Help

    Posted 03-19-2026 07:58 AM

    The CLOB error is on the descrlong fields.

    If they are commented out in the select and group by, the SQL runs.



    ------------------------------
    Daron Wild
    Senior PeopleSoft Developer
    University of Cambridge
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------

    Alliance 2026 Recordings are here!


  • 6.  RE: ListAgg Expression Help

    Posted 03-19-2026 07:59 AM

    Hi Daron,  I just took a look at my query and found the issue was because of A.DESCRLONG and C.DESCRLONG. I've removed them and now the listagg works as expected.  Thanks for your help.






    ------------------------------
    Pheng Xiong Ph.D.
    Senior Associate Registrar
    Rochester Institute of Technology
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------

    Alliance 2026 Recordings are here!


  • 7.  RE: ListAgg Expression Help

    Posted 03-19-2026 08:15 AM
    One other thing that might be helpful... if you are getting a CLOB error when trying to return aggregated fields, you can create an expression to essentially convert them from long character fields to normal char fields.

    I usually do this by using a SUBSTR() expression and setting the "expression type" to Character.

    image.png

    Usually a length of 500 is sufficient for me, but you can change that amount to match your needs.

    This is helpful if you really do need the data returned in the long character fields returned alongside your aggregates.

    Best,

    Jeffrie

    --
    Jeffrie Brooks | BUSINESS SYSTEM ANALYST
    UNIVERSITY OF MICHIGAN | INFORMATION AND TECHNOLOGY SERVICES
    734-647-8763 | jedobr@umich.edu



    Alliance 2026 Recordings are here!


  • 8.  RE: ListAgg Expression Help

    Posted 03-19-2026 09:12 AM
    I've been able to go up to a length of 4000 with the substr option on the CLOB that Jeffrie mentions.  I've encountered some long course description fields and have "chunked" it into multiple expressions/fields (1-4000, 4001-8000, etc) for the output.

    David Ehrlich | Senior Business System Analyst

    Duke University | Student Information Services & System (SISS)

    david.ehrlich@duke.edu | 919-684-1206

    www.sissoffice.duke.edu





    Alliance 2026 Recordings are here!


  • 9.  RE: ListAgg Expression Help

    Posted 03-19-2026 04:46 AM

    It does not look like you can directly use advanced Oracle functions like
    LISTAGG(...) WITHIN GROUP (ORDER BY ...) in the standard query UI. The workaround would be to create a View and use that view to select the required output.



    ------------------------------
    Nomalungelo Singonzo
    Senior Applications Developer
    University of the Witwatersrand
    ------------------------------

    Message from the HEUG Marketplace:
    ------------------------------
    Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the HEUG Marketplace.
    ------------------------------

    Alliance 2026 Recordings are here!


  • 10.  RE: ListAgg Expression Help

    Posted 03-19-2026 11:14 AM

    Hello Max -

    A quick query of Google indicates that LISTAGG does not directly support CLOBs.  

    With Oracle, there is a database initialization parameter MAX_STRING_SIZE.  By default it's set to 4000 characters.  If a concatenation like LISTAGG creates a string longer than that then Oracle throws an error.  It is possible to set MAX_STRING_SIZE to some other value, all the way up to 32K, but it's not a trivial exercise.

    To mitigate the character overflow situation you can add ON OVERFLOW TRUNCATE to your LISTAGG function:

    LISTAGG(your_column, ',' ON OVERFLOW TRUNCATE '...')  WITHIN GROUP (ORDER BY your_column) ;

    Hope this helps, or at least is a good workaround to let you deliver your query while you continue working on the issue.



    ------------------------------
    Ray Martin
    Enterprise Applications Engineer
    Azusa Pacific University
    ------------------------------

    ------------------------------

    Alliance 2026 Recordings are here!