I guess I am turning into more of a power-user. Nonetheless, I have had some
problems using exec() with SPARQL statements where the GRAPH URI is a variable.
In this case, I must use { GRAPH ?? { ?? mesh:altLabel ?? } } for instance as
below. I also see no way to specify the language code when I am updating
strings in this way except for sprintf() and then SPARQL_EVAL - I do not think
old_label carries a language. Advice is appreciated, but not expected.
Note that I do not really need the loop for rdfs:label, but I will need it
later for a custom subProperty of rdfs:label which is meshv:altLabel which does
have cardinality >1.
CREATE PROCEDURE meshrdf_prefix_label(in graph_uri varchar, in subj_uri
varchar, in prefix varchar) {
DECLARE state, msg, descs, chandle, arow any;
state := '00000';
exec('SPARQL PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label WHERE { GRAPH ?? { ?? rdfs:label ?label .
FILTER(lang(?label) = \'en\') } }',
state, msg, vector(graph_uri, subj_uri), 100, descs, null, chandle);
IF (state <> '00000')
signal(state, msg);
WHILE (exec_next(chandle, state, msg, arow) = 0) {
IF (state <> '00000')
signal(state, msg);
DECLARE old_label, new_label varchar;
old_label := arow[0];
new_label := sprintf('%S %S', prefix, old_label);
DECLARE stmt varchar;
stmt := sprintf('SPARQL PREFIX rdfs:
<http://www.w3.org/2000/01/rdf-schema#>
WITH <%S> DELETE { <%S> rdfs:label "%S"@en } INSERT {
<%S> rdfs:label "%S"@en }',
graph_uri, subj_uri, old_label, subj_uri, new_label);
exec(stmt, state, msg, vector(), 1, null, null);
IF (state <> '00000')
signal(state, msg);
}
exec_close(chandle);
}
Dan Davis, Systems/Applications Architect (Contractor),
Office of Computer and Communications Systems,
National Library of Medicine, NIH
------------------------------------------------------------------------------
_______________________________________________
Virtuoso-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/virtuoso-users