-
Ich hatte mir da mal was gebastelt:
<code>
CREATE FUNCTION USMOD_16/DATESERIAL
(YEAR INTEGER,
MONTH INTEGER,
DAY INTEGER)
RETURNS DATE
LANGUAGE RPGLE
EXTERNAL NAME 'USMOD_16/DATSER'
DETERMINISTIC
RETURNS NULL ON NULL INPUT
NO SQL
NO EXTERNAL ACTION
PARAMETER STYLE SQL
ALLOW PARALLEL
NOT FENCED
hactgrp(*caller) dftactgrp(*no) datfmt(*iso)
d SYear s 10I 0
d SMonth s 10I 0
d SDay s 10I 0
d SQLDate s d
d SYear_Ind s 5I 0
d SMonth_Ind s 5I 0
d SDay_Ind s 5I 0
d SQLDate_Ind s 5I 0
d SQLState s 5
d FuncName s 139 varying
d SpecName s 128 varying
d DiagMsg s 70 varying
c *entry plist
c parm SYear
c parm SMonth
c parm SDay
c parm SQLDate
c parm SYear_Ind
c parm SMonth_Ind
c parm SDay_Ind
c parm SQLDate_Ind
c parm SQLState
c parm FuncName
c parm SpecName
c parm DiagMsg
c*
c/free
if SYear_ind <> *zero
or SMonth_ind <> *zero
or SDay_ind <> *zero;
SQLDate_ind = -1; // Ergebnis ist NULL
else;
monitor;
SQLDate = %date('0001-01-01')
+ %Years(SYear-1)
+ %Months(SMonth-1)
+ %Days(SDay-1);
on-error *all;
SQLDate_ind = -1; // Ergebnis ist NULL
endmon;
endif;
/end-free
c*
c return
</code>
Man kann das auch alles native in einer SQL-Prozedur kodieren.
Der Aufruf erfolgt dann in SQL so:
dateserial(JJJJ, MM, TT + n)
Bei Fehlern wird halt NULL geliefert.
Kleine Schmankerln:
1. des Monats: dateseriel(JJJJ, MM, 1)
Letzter des Monats: dateseriel(JJJJ, MM+1, 0)
Similar Threads
-
By christian_lettner in forum NEWSboard Programmierung
Antworten: 2
Letzter Beitrag: 16-11-06, 11:15
-
By FNeurieser in forum NEWSboard Programmierung
Antworten: 3
Letzter Beitrag: 11-10-06, 15:53
-
By malzusrex in forum IBM i Hauptforum
Antworten: 8
Letzter Beitrag: 19-09-06, 12:04
-
By Kaufmann in forum IBM i Hauptforum
Antworten: 11
Letzter Beitrag: 28-06-06, 15:11
-
By loeweadolf in forum NEWSboard Programmierung
Antworten: 2
Letzter Beitrag: 01-06-06, 10:43
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- You may not post attachments
- You may not edit your posts
-
Foren-Regeln
|
Erweiterte Foren Suche
Google Foren Suche
Forum & Artikel Update eMail
AS/400 / IBM i
Server Expert Gruppen
Unternehmens IT
|
Kategorien online Artikel
- Big Data, Analytics, BI, MIS
- Cloud, Social Media, Devices
- DMS, Archivierung, Druck
- ERP + Add-ons, Business Software
- Hochverfügbarkeit
- Human Resources, Personal
- IBM Announcements
- IT-Karikaturen
- Leitartikel
- Load`n`go
- Messen, Veranstaltungen
- NEWSolutions Dossiers
- Programmierung
- Security
- Software Development + Change Mgmt.
- Solutions & Provider
- Speicher – Storage
- Strategische Berichte
- Systemmanagement
- Tools, Hot-Tips
Auf dem Laufenden bleiben
|
Bookmarks