Solved

DB2 Function LISTAGG failing with SQL0440N

Posted on 2014-12-19
1
1,270 Views
Last Modified: 2015-02-18
We have several DB2 Servers and multiple instances all running DB2 LUW (windows) DB2  V9.7 Fixpack 9

a call to DB2 Function LISTAGG is working against some of the databases - and failing in others.

Here is the SQL:  

SELECT COL1, COL2, LISTAGG(AGT_DESGNT_CD,',') WITHIN GROUP (ORDER BY AGT_DESGNT_CD ) AS AGT_DESGN_DESC
 FROM myschema. mytable
GROUP BY COL1, COL2
ORDER BY COL1, COL2

Here is the error:
Error during Prepare
 42884(-440)[IBM][CLI Driver][DB2/NT] SQL0440N  No authorized routine named "LISTAGG" of type "FUNCTION" having compatible arguments was found.  SQLSTATE=42884

I cannot find a pattern as to why it is failing in some databases and not in others.   On one Server, I have 2 Databases - both in the same instance - and it is failing in one and not the other.
0
Comment
Question by:itsonlyme4
1 Comment
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 40510770
Hi me,

Functions in DB2 look a lot like functions in object oriented languages in that the same function name can be used over and over.

SQL0440N  No authorized routine named "LISTAGG" of type "FUNCTION" having compatible arguments was found.  SQLSTATE=42884

The error that you're seeing indicates that there is no definition of LISTAGG that has a matching parameter type list.  That is, it may exist with parameters (varchar, varchar), but not (int, varchar).


Check the version of DB2 on all of the servers.  It may be that DB2 on the server that's giving you trouble is older than the others and LISTAGG isn't in the system library.

Check the system library (sysibm) and make sure that LISTAGG is defined there.

LISTAGG is recursive.  It could be that the result is longer than the default limit of 4000 characters.  (Though I would expect a different error.)  Try recasting the source name.  DB2 recursive SQL propogates the source length through the entire query.

  LISTAGG(CAST(AGT_DESGNT_CD AS VARCHAR(10000)), ',')


Good Luck,
Kent
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question