Hello,

The attached .sql file contains definitions of user defined aggregates
GROUP_CONCAT and SAMPLE that matches SPARQL 1.1 spec. If needed, they
can be used to not wait for the VOS release with these function
built-in. However it's better to not load the file in vain if there's no
real immediate need for that, because these functions will not be
upgraded automatically by new built-in versions, if these functions are
changed in some distant future (procedures created by user takes
priority over any built-in things).

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com

create procedure DB.DBA.GROUP_CONCAT_INIT (inout _env any)
{
  _env := 0;
}
;


create procedure DB.DBA.GROUP_CONCAT_ACC (inout _env any, in token varchar, in delim varchar)
{
--  if (185 <> __tag (_env))
--    _env := string_output();
--  else if (delim is not null)
--    http (cast (delim as varchar), _env);
--  http (cast (token as varchar), _env);
  if (__tag of varchar <> __tag (_env))
    _env := cast (token as varchar);
  else if (delim is not null)
    _env := concat (_env, cast (delim as varchar), cast (token as varchar));
  else
    _env := concat (_env, cast (token as varchar));
}
;


create procedure DB.DBA.GROUP_CONCAT_FIN (inout _env any)
{
--  if (185 <> __tag (_env))
--    return '';
--  return string_output_string (_env);
  if (__tag of varchar <> __tag (_env))
    return '';
  return _env;
}
;

grant execute on DB.DBA.GROUP_CONCAT_INIT to public
;
grant execute on DB.DBA.GROUP_CONCAT_ACC to public
;
grant execute on DB.DBA.GROUP_CONCAT_FIN to public
;

create aggregate DB.DBA.GROUP_CONCAT (in token varchar, in delim varchar) returns varchar
  from DB.DBA.GROUP_CONCAT_INIT, DB.DBA.GROUP_CONCAT_ACC, DB.DBA.GROUP_CONCAT_FIN
order
;



create procedure DB.DBA.SAMPLE_INIT (inout _env any)
{
  _env := null;
}
;


create procedure DB.DBA.SAMPLE_ACC (inout _env any, in sample any)
{
  if (_env is not null)
    return;
  _env := sample;
}
;


create procedure DB.DBA.SAMPLE_FIN (inout _env any)
{
  return _env;
}
;

grant execute on DB.DBA.SAMPLE_INIT to public
;
grant execute on DB.DBA.SAMPLE_ACC to public
;
grant execute on DB.DBA.SAMPLE_FIN to public
;

create aggregate DB.DBA.SAMPLE (in sample any) returns any
  from DB.DBA.SAMPLE_INIT, DB.DBA.SAMPLE_ACC, DB.DBA.SAMPLE_FIN
order
;

Reply via email to