Solved

DB2 Function LISTAGG failing with SQL0440N

Posted on 2014-12-19
1
1,114 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:
Kdo 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now