473,378 Members | 1,175 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,378 software developers and data experts.

iSeries DB2/UDB V5R2 - UDF not found problem...

Here's a simple function:

CREATE FUNCTION datawhse.num2cdate( inval INT) RETURNS CHAR
LANGUAGE SQL
BEGIN
RETURN(nullif(substr(CHAR(inval +19000000),1,4)||'-'||substr(CHAR(inval
+19000000),5,2)||'-'||substr(CHAR(inval +19000000),7,2)||' 00:00:00:000',
'1900-01-01 00:00:00:000'));
END
Rather than doing using that whole numeric date to character date conversion
mess above, we can just use this SQL function that encapsulates it. It
compiles, and I can see the function object both via the WRKOBJ CL command
(appears as a *SVRPGM object) and by querying the QSYS2.SYSROUTINES view.

However, when I try to actually use the function, I get this error message:

select datawhse.num2cdate(somedate) from datawhse.testdate
NUM2CDATE in DATAWHSE type *N not found.

Even though I'm specifying the function schema, it's not able to find the
function. What am I missing here? Any suggestions appreciated!

Thx,
Dave
Nov 12 '05 #1
4 5913
Dave,

What's the datatype of somedate?

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
It's DECIMAL(7,0).

"Serge Rielau" <sr*****@ca.eye-be-em.com> wrote in message
news:ca**********@hanover.torolab.ibm.com...
Dave,

What's the datatype of somedate?

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Nov 12 '05 #3
Dave Sisk wrote:
It's DECIMAL(7,0).

"Serge Rielau" <sr*****@ca.eye-be-em.com> wrote in message
news:ca**********@hanover.torolab.ibm.com...
Dave,

What's the datatype of somedate?

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab



See examples under "Using qualified function reference" here:
http://publib.boulder.ibm.com/iserie...bafymst233.htm

You may need something like:
select datawhse.num2cdate(integer(somedate)) from ...

--
Karl Hanson
Nov 12 '05 #4
Yep. integer is upstream from decimal. Function resolution can't swim
against the promotion chain.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5

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

Similar topics

6
by: Thad Rizzi | last post by:
My webserver is an iSeries and I want to run some PHP scripts on it using SQL to access data on the iSeries. Does anyone have any exapmles or resources on the most effective way to do this? I...
4
by: Dave Sisk | last post by:
Hi folks: We have a script containing DDL statements to create tables and indexes, etc. On DB2 for Unix, I'd do a "db2 -tvf script_name.sql -z logfile_name.log", but I don't think that works on...
5
by: Dave Sisk | last post by:
Hey folks: I'm trying to do this: CREATE TRIGGER datawhse.emp_ti AFTER INSERT ON emp REFERENCING NEW AS n FOR EACH ROW MODE DB2ROW BEGIN DECLARE v_rrn DECIMAL(15,0);
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
4
by: Robert Schneider | last post by:
Hi, I have got a problem inserting data of a file (both, binary and text) into a blob column. It is created with "Data BLOB(2G)" in the sql statement (so the name of the column is obviously...
1
by: Yanik Reid | last post by:
When I run the following vb.net code, I'm not able to acces the my database AMFLIB. I use to be able to access AMFLIB with the old ODBC driver from IBM iSeries Access but now I want to use the...
1
by: tom.eeraerts | last post by:
Hello, I have a problem migrating an application from v5r2 to v5r3. The problem is with the prepared statements. To see what the problem is, i extracted a small piece of code and debugged the...
2
by: chmmr | last post by:
Hello, I would like to ask if there are any differences between DB2 in these versions (e.g. support of triggers, Java stored procedures and such). Also, does anyone know from which DB2 AS/400...
1
by: Saharian | last post by:
Hi all, I am new to DB2. I want to configure replication between DB2 9.5-C Express and DB2 Iseries V5R2. I am maintaining a small database(around 50 tables) on local DB2 9.5. I want to keep...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.