Using SUBSTR generates error

6 views
Skip to first unread message

David Großmann

unread,
Nov 18, 2022, 1:39:37 AM11/18/22
to ontop4obda
Good morning everybody,

I try to perform a simple substring on a query. But when I start the query i get an error:

"Error parsing SPARQL query: Encountered ""substr" "SUBSTR""" at line 3, column 8.
Was expecting on of:
..."

PREFIX : <http://www.semanticweb.org/grossmann/ontologies/kis-ontology#>

SELECT SUBSTR( ?c,1,3 ) (count( ?c) as ?Anzahl) WHERE {

?code rdf:type :KrebsregisterDiagnoseRLP ;
          :meddok_EPSNR ?epi ;
          :meddok_DOKUTYPEN ?typ ;
          :meddok_CODE_GES ?c ;
    :meddok_KLARTEXT ?text;
    :meddok_BEHNR ?behnr
.
?code a :Entlassdiagnose
.
?fäll a :Fall ;
          :eps_EPSNR ?epi ;
          :eps_AUFNR ?auf ;
          :eps_PATNR ?patnr
.
?beha a :Behandlung ;
          :bzt_EPSNR ?epi ;    
    :bzt_AUFNAHMEALTER ?AufAlter;
    :bzt_BEHNR ?behnr;
    :bzt_EPSNR ?epi
.
    FILTER (?AufAlter > 15)
?person a :Patient ;
          :pat_PATNR ?patnr;
          :pat_GORT ?gort
.

}
group by ?c ?text
order by DESC (?Anzahl )

But I cannot find any other requirements using SUBSTR, so why is my query wrong? Could you please give me a hint?

And by the way is there a possibility to show line an column numbers in the SPARQL query editor?

Kind regards,
David

conpco...@googlemail.com

unread,
Nov 18, 2022, 2:03:54 AM11/18/22
to ontop4obda
you should put SUBSTR in brackets as any other function in the projection part, i.e.

SELECT (SUBSTR(?c, 1, 3) AS ?foo)

David Großmann

unread,
Nov 18, 2022, 2:08:06 AM11/18/22
to ontop4obda
Thanks, yes of course like I did with count. Sometimes it's to easy.

Have a nice day!

Reply all
Reply to author
Forward
0 new messages