Solved

DB2 Function LISTAGG failing with SQL0440N

Posted on 2014-12-19
1
1,449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

622 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