Hi Sebastian,
You cannot declare cursor as a statement string, the cursor can be declared as :
declare cr cursor for select x from table where ...
In your case when you need to execute a statement give to the procedure as
string literal, you can use exec () and and exec_next () , see
http://docs.openlinksw.com/virtuoso/fn_exec.html .
See example in the above page, the result will be in the 'rows' variable.
Best Regards,
Mitko
On Nov 23, 2011, at 10:04 PM, Sebastian Trüg wrote:
> Hello list,
>
> I am trying to write a stored procedure which deletes a set of graphs
> matching a query. This is what I have so far:
>
> create procedure nrl_drop_graphs(IN QUERY_BASE STRING)
> {
> DECLARE query STRING;
> query := query_base + ' LIMIT 1000';
>
> declare cnt integer;
> cnt := 0;
>
> while(1)
> {
> declare it cursor for sparql query;
> open it;
> declare v any;
> while(1)
> {
> WHENEVER NOT FOUND goto done;
> FETCH it INTO g;
> vector_concat(v, g);
> }
> done: ;
> close it;
>
> if(length(v)=0) return;
>
> for(any g in v)
> {
> cnt := cnt + 1;
> sparql drop graph g;
> }
> }
> }
>
> The idea is to get all the graphs in batches of 1000 and drop them one
> by one since that is not possible with SPARUL (at least not in 6.1.4).
>
> It fails at the "declare cursor" since it is not happy with the
> "sparql". This is the first time I try my luck with stored procedures so
> the code may contains lots of stupidities. :P
>
> Thanks for your help.
>
> Cheers,
> Sebastian
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Virtuoso-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users
--
Mitko Iliev
Developer Virtuoso Team
OpenLink Software
http://www.openlinksw.com/virtuoso
Cross Platform Web Services Middleware