Stored Procedures in Stardog

Good morning,

Is there any way to store and launch queries with parameters? something like stored procedures?. I know there is an option to store fixed queries, but I want to save queries in the database and execute them passing parameters. Currently, I have to modify the query string changing the parameters in my app.

Thanks in advance.

You can store queries with $variables in them and pass in values for them at query time. How are you wanting to do this (HTTP, Java, CLI, something else)?

I'm using node.js, could you give an example of the bind param for javascript or HTTP API?
I know the command using linux console:
stardog query -r -b p1=ex:Ind_1 -- Database StoredQueryName

Never mind, I found the answer here:
https://stardog.docs.apiary.io/#introduction/query-bindings

Thanks.

Hi again,

I have realized that it is not possible to use prefixes to bind variables with the HTTP API, with CLI it is possible:
stardog query -r -b p1=ex:Ind_1 -- Database StoredQueryName

But with HTTP API:
http://localhost:5820/Database/query?query=StoredQueryName&$p1=ex:Ind_1

Returns:
{"message":"The query binding 'ex:Ind_1' is a malformed Turtle value"}

If I use the full individual URI the query is done correctly:

http://localhost:5820/Database/query?query=StoredQueryName&$p1=<http://demo.ontology.test/demo1#Ind_1>

Is there anyone from support team that can confirm if it is possible to use prefixes in param binding with the HTTP API ?

No, the parameters passed to the HTTP API should be full IRIs at this point. CLI does an extra step to turn prefixed names into full IRIs before sending them to the server. We will look into making this change in the server.

Best,
Evren

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.