Hi All,
I am trying to understand using Xquery custom functions in usage with oracle sql queries.
Kindly help me understanding these with some examples.
example of custom function from OTN:
select * from
xmltable('declare function local:reverse($a)
{
if (string-length($a) != 0) then
concat(substring($a,string-length($a),1), local:reverse(substring($a,1,string-length($a)-1)))
else ()
}; (: eof
declare function local:sum($a)
{
if (string-length($a) != 0) then
xs:integer(substring($a,1,1)) + xs:integer(local:sum(substring($a,2)))
else (0)
}; (: eof
declare function local:prod($a)
{
if (string-length($a) != 0) then
xs:integer(substring($a,1,1)) * xs:integer(local:prod(substring($a,2)))
else (1)
}; (: eof
for $i in 1 to 10000
where $i - local:reverse(xs:string($i)) = local:sum(xs:string($i)) + local:prod(xs:string($i))
return $i' columns x integer path '.')