Unix Technical Forum

need help with UDF

This is a discussion on need help with UDF within the DB2 forums, part of the Database Server Software category; --> MAXRC is UDF Returns GREATEST Value of list of COLUMNS – TYPE CHARACTER Example of use: SELECT EMPNO, FIRSTNME,MIDINIT,LASTNAME,WORKDEPT, ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-04-2008, 07:23 AM
lenygold via DBMonster.com
 
Posts: n/a
Default need help with UDF

MAXRC is UDF Returns GREATEST Value of list of COLUMNS – TYPE CHARACTER
Example of use:
SELECT EMPNO, FIRSTNME,MIDINIT,LASTNAME,WORKDEPT,
MAXRC(FIRSTNME,MIDINIT,LASTNAME,WORKDEPT) AS MAX_IN_ROWS
FROM EMPLOYEE;

FIRSTNME MIDINIT LASTNAME WORKDEPT
MAX_IN_ROWS

------------ ------- --------------- -------- --------------------------------
----------------------------------------------------
CHRISTINE I HAAS A00
I

MICHAEL L THOMPSON B01
THOMPSON

SALLY A KWAN C01
SALLY

JOHN B GEYER E01
JOHN

IRVING F STERN D11
STERN

EVA D PULASKI D21
PULASKI

But when i try use it with Temp tables it is not working:

WITH T1(D_KEY,D_NAME) AS
(VALUES(1,'Barbara'),
(2,'John'),
(3,'Steve')),
T2 (T_KEY,T_NAME) AS
(VALUES (1,'Wattson'),
(2, 'Jackson'),
(3, 'Henry'),
(1,'Smith'))

SELECT D_NAME,T_NAME,MAXRC(T1.D_NAME,T2.T_NAME)
FROM T1,T2;
i got following error message
No authorized routine named "MAXRC" of type "FUNCTION
" having compatible arguments was found.

sqlcode: -440

Any ideas what is wrong?
Thank's in advance Leny G.

--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200803/1

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-04-2008, 07:23 AM
lenygold via DBMonster.com
 
Posts: n/a
Default Re: need help with UDF

lenygold wrote:
>MAXRC is UDF Returns GREATEST Value of list of COLUMNS – TYPE CHARACTER
>Example of use:
>SELECT EMPNO, FIRSTNME,MIDINIT,LASTNAME,WORKDEPT,
> MAXRC(FIRSTNME,MIDINIT,LASTNAME,WORKDEPT) AS MAX_IN_ROWS
> FROM EMPLOYEE;
>
>FIRSTNME MIDINIT LASTNAME WORKDEPT
>MAX_IN_ROWS
>
>------------ ------- --------------- -------- --------------------------------
>----------------------------------------------------
>CHRISTINE I HAAS A00
>I


Never mind. I find what is wrong. My Udf started with 3 arguments and more. I
fixed it
>
>MICHAEL L THOMPSON B01
>THOMPSON
>
>SALLY A KWAN C01
>SALLY
>
>JOHN B GEYER E01
>JOHN
>
>IRVING F STERN D11
>STERN
>
>EVA D PULASKI D21
>PULASKI
>
>But when i try use it with Temp tables it is not working:
>
>WITH T1(D_KEY,D_NAME) AS
> (VALUES(1,'Barbara'),
> (2,'John'),
> (3,'Steve')),
> T2 (T_KEY,T_NAME) AS
> (VALUES (1,'Wattson'),
> (2, 'Jackson'),
> (3, 'Henry'),
> (1,'Smith'))
>
> SELECT D_NAME,T_NAME,MAXRC(T1.D_NAME,T2.T_NAME)
> FROM T1,T2;
>i got following error message
>No authorized routine named "MAXRC" of type "FUNCTION
>" having compatible arguments was found.
>
>sqlcode: -440
>
>Any ideas what is wrong?
>Thank's in advance Leny G.


--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200803/1

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-04-2008, 07:23 AM
Serge Rielau
 
Posts: n/a
Default Re: need help with UDF

Either redefine your function to accept VARCHAR, or cast your input to CHAR.
CHAR is lower in the promotion chain that VARCHAR.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:48 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com