OSB 12c custom xquery functions
Here are the some of
OSB custom xquery function that came across:
1. mmddyyyy to date conversion:
declare function
ns1:mmddyyyy-to-date
( $dateString
as xs:string? ) as xs:date? {
if
(empty($dateString))
then ()
else
xs:date(concat(substring($dateString,7,4),'-',
substring($dateString,1,2),'-',
substring($dateString,4,2)))
} ;
2. day of week:
declare
function ns1:day-of-week
( $date as
xs:date? ) as xs:integer? {
if
(empty($date))
then ()
else
xs:integer(($date - xs:date('1901-01-06'))
div xs:dayTimeDuration('P1D')) mod 7
} ;
3. day of week name:
declare
function ns1:day-of-week-name
( $date as
xs:date? ) as xs:string? {
('Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday')
[ns1:day-of-week($date) + 1]
} ;
4. month from date name:
declare
function ns1:month-from-date-name
( $date as
xs:anyAtomicType? ) as xs:string? {
('January', 'February', 'March', 'April', 'May', 'June',
'July',
'August', 'September', 'October', 'November', 'December')
[month-from-date(xs:date($date))]
} ;
5. MONTHNAME from date:
declare
function ns1:MONTHNAME-from-date
( $date as
xs:anyAtomicType? ) as xs:string? {
('JAN',
'FEB', 'MAR', 'APR', 'MAY', 'JUN',
'JUL',
'AUG', 'SEP', 'OCT', 'NOV', 'DEC')
[month-from-date(xs:date($date))]
} ;
6. date to ddMONyy:
declare function
ns1:date-to-ddMONyy
( $dateString
as xs:date? ) as xs:string? {
let
$dateStr := string($dateString)
return
if
(empty($dateString))
then ()
else
string(concat(substring($dateStr,9,10),'-',
ns1:MONTHNAME-from-date($dateStr),'-',
substring($dateStr,3,2)))
} ;
Thank you for explaining OSB xquery functions it helps in my Oracle Service Bus Administration Training in middle-ware technologies.
ReplyDelete