473,385 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

what wrong with my UDF use?

CREATE FUNCTION dates(start DATE, end DATE)
RETURNS TABLE(dt DATE)
RETURN
WITH REC (DT)
AS
(VALUES(DATE(START))
UNION ALL
SELECT DT + 1 DAY FROM REC WHERE DT < END)
SELECT DT FROM REC;

SELECT DATES('2007-01-01','2007-11-01')
FROM SYSIBM.SYSDUMMY1;
and i got an error:

sqlcode: -440

sqlstate: 42884
No authorized routine named "DATES" of type "FUNCTION
" having compatible arguments was found.

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

Sep 1 '08 #1
3 1661
lenygold via DBMonster.com wrote:
CREATE FUNCTION dates(start DATE, end DATE)
RETURNS TABLE(dt DATE)
RETURN
WITH REC (DT)
AS
(VALUES(DATE(START))
UNION ALL
SELECT DT + 1 DAY FROM REC WHERE DT < END)
SELECT DT FROM REC;

SELECT DATES('2007-01-01','2007-11-01')
FROM SYSIBM.SYSDUMMY1;
and i got an error:

sqlcode: -440

sqlstate: 42884
No authorized routine named "DATES" of type "FUNCTION
" having compatible arguments was found.
Your function is defined on DATE. You call it with VARCHARs.
Try this:
CREATE FUNCTION dates(start VARCHAR(26), end VARCHAR(26))
RETURNS TABLE(dt date) RETURN SELECT * FROM TABLE(dates(date(start),
date(end))) AS D;

Lastly the function is a table function, so it needs to be called in the
FROM clause:
SELECT * FROM TABLE(dates('2007-01-01','2007-11-01')) AS D

You can a an integer counter with cut-off to the recursion so DB2
recognizes that the recursion in not infinite and avoids the warning
(not sure why it doesn't recognize the climbing date....)

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Sep 1 '08 #2
There are two isuues which I noticed.
1) Data type of parameters and arguments are differnt.
You can call it like this:
DATES(DATE('2007-01-01'), DATE('2007-03-01'))

or you can define it like this:
CREATE FUNCTION dates(start VARCHAR(10), end VARCHAR(10))
......

2) Syntax of calling TABLE UDF is as following.
SELECT *
FROM TABLE( DATES(DATE('2007-01-01'), DATE('2007-03-01')) ) AS d
;
Sep 1 '08 #3
Thank you very much for your help

Tonkuma wrote:
>There are two isuues which I noticed.
1) Data type of parameters and arguments are differnt.
You can call it like this:
DATES(DATE('2007-01-01'), DATE('2007-03-01'))

or you can define it like this:
CREATE FUNCTION dates(start VARCHAR(10), end VARCHAR(10))
.....

2) Syntax of calling TABLE UDF is as following.
SELECT *
FROM TABLE( DATES(DATE('2007-01-01'), DATE('2007-03-01')) ) AS d
;
--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200809/1

Sep 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
28
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr();...
56
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
3
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.