Glenn,
This procedure was running without problems on our V5R3 system.
But I'll give it a shot and drop/create it with "numeric(10, 0)" instead of (8, 0).
Met vriendelijke groeten / Best regards,
Peter Colpaert
Software Engineer - PLM Development Team
IT Operations Cluster Benelux, Philips IT
Philips Consumer Luminaires
Industrieterrein Satenrozen 11, 2550 Kontich, Belgium
Tel: (+32) 3/459 13 17
Email: Peter.Colpaert@xxxxxxxxxxx
Working from home on Wednesdays
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Glenn Gundermann
Sent: maandag 9 december 2013 11:06
To: Midrange RPG400 List
Subject: Re: SQL UDF problem
Hi Peter,
I'm not at a computer to test but could it be that your procedure is returning a numeric 8,0 and your %dec says 10,0?
Glenn Gundermann
-----Original Message-----
From: "Colpaert, Peter" <Peter.Colpaert@xxxxxxxxxxx>
Sender: rpg400-l-bounces@xxxxxxxxxxxx
Date: Mon, 9 Dec 2013 08:42:01
To: rpg400-l@xxxxxxxxxxxx<rpg400-l@xxxxxxxxxxxx>
Reply-To: "RPG programming on the IBM i \(AS/400 and iSeries\)" <rpg400-l@xxxxxxxxxxxx>
Subject: SQL UDF problem
Hi group,
Yesterday evening we migrated (finally) from our V5R3 system to a brand new enterprise system at V7R1.
All seemed well until I tried to use a UDF in SQL this morning. It takes in a date in numeric ISO format, and should return a date in excel format (# of days since 01/01/1900).
However, it always returns zero.
I re-created the function using the following syntax:
create function colpaerp.isotoexcel(decimal(8, 0)) returns numeric(8, 0) external name 'SRVPGMLIB/SQLUDF(ISOTOEXCEL)'
language rpgle
parameter style db2sql
no sql
deterministic
no external action
returns null on null input
allow parallel;
This is the source of the function in the service program:
P IsoToexcel b Export
d IsoToExcel pi 8s 0
d IsoDate 8p 0 const
D Xls_StartDate S D inz(d'1900-01-01')
D retVal s 8s 0 inz
/free
Reset retVal;
test(de) *iso IsoDate;
If %error;
Else;
If IsoDate > *zeros;
retVal = %diff(%date(IsoDate:*iso):xls_startdate:*d) + 2;
EndIf;
Endif;
Return %dec(retVal:10:0);
/end-free
p IsoToExcel e
When I debugged the function, the retVal contained the correct value, but in the SQL result it was zero.
Is there a difference between V5R3 and V7R1 when creating the function?
FWIW, the V5 system was first restored on a new V6 system, which was subsequently upgraded to V7.
Any help would be greatly appreciated.
Met vriendelijke groeten / Best regards,
Peter Colpaert
Software Engineer - PLM Development Team IT Operations Cluster Benelux, Philips IT
Philips Consumer Luminaires
Industrieterrein Satenrozen 11, 2550 Kontich, Belgium
Tel: (+32) 3/459 13 17
Email: Peter.Colpaert@xxxxxxxxxxx<mailto:Peter.Colpaert@xxxxxxxxxxx>
Working from home on Wednesdays
________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.