Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DB2 Function LISTAGG failing with SQL0440N

Posted on 2014-12-19
1
Medium Priority
?
1,556 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 46

Accepted Solution

by:
Kent Olsen earned 2000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

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 (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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

722 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