Elegant way to get named vars from EXEC SPARQL


I am looking for an elegant way to get named variables (instead of row[i] ) for SPARQL result received from EXEC function.

  1. Issue

When I use syntax

FOR (sparql SELECT ?startDate ... )

I can use variables provided by sparql, e.g. " ?startDate ".

When I use EXEC

declare qr, state, data, meta, message, ret, r any; state := '00000';
qr := sprintf  ('sparql SELECT distinct ?startDate from %s ... ' , graph)
exec (qr, state, message, vector (), vector('use_cache', 1, 'max_rows', 0), meta, data);
foreach (any row in data) DO { ... }

I have row[i] instead of the named vars. It’s not convenient.

  1. An acceptable solution
create procedure XYZ.DBA.convert_exec_data( 
IN meta vector,
IN row vector,
OUT result vector
for (declare i,l int, i := 0, l := length (meta[0]); i < l; i := i + 1)
if(i = 0){result := vector(meta[0][i][0], concat(row[i]));}
else{ result := vector_concat (result, vector(meta[0][i][0], concat(row[i])));}

And then use it in DO loop:

foreach (any row in data) DO {
declare rw vector;
XYZ.DBA.convert_exec_data( meta, row, rw);
http(get_keyword ('startDate', rw));

The syntax looks better now but still not as clear that ?startDate .

  1. Question

Is any one know how to get simple named variables for “data” received from “exec” function ?

Best regards.