0

How to insert insert query with "where" condition in 4store sparql As far as I have searched I got to know that we have to use curl command for the same.I tried using this

         Process p = Runtime.getRuntime().exec(new String[]{"bash","-c","curl -i -d 'update=INSERT+DATA+{+?subject2+<http://www.w3.org/2002/07/owl/sameAs>+?subject3+.+}+WHERE+{+?subject2+<http://localhost:2020/vocab/Schema_feature>+\""+first[0]+"\"+.+?subject3+<http://localhost:2020/vocab/Schema_feature>+\""+first[1]+"\"+.+}' http://localhost:8000/update/"});

but it is saying "WHERE" should not be there.What I am doing wrong? Is there any other way to do that With simple insert command I am not able to work in sparql

It is working but for ?subject3 it is entering empty value.I don't know why.When I check the triples for where condition they are showing values

1 Answers1

2

You don't

insert data { ... } where { ... }

You can either insert constant data with:

insert data { ... }

or you can compute the data to insert with

insert { ... } where { ... }

It looks like that latter one is what you want here.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • It is working but for ?subject3 it is entering empty value.I don't know why – henry mathew Jun 21 '15 at 11:34
  • 1
    @henrymathew WIthout seeing the query you're actually executing, and without seeing your data, we can't really know either. What do you mean by "empty value"? – Joshua Taylor Jun 21 '15 at 19:09
  • I have checked with select statement for where clause it is working fine infact when I run a construct it is showing results – henry mathew Jun 22 '15 at 04:33
  • @henrymathew So everything works now? – Joshua Taylor Jun 22 '15 at 12:22
  • no.I am saying that "the where returns the results" but triples matching the first clause are inserted only hence blank node for predicate – henry mathew Jun 22 '15 at 12:53
  • if you write something like `insert { ?x :p ?y } where { ?x :a :b . ?y :c :d }`, you won't insert *anything* unless both `?x :a :b` and `?y :c :d` matched. Without seeing the actual queries your running and the data in your triplestore, we can't really help any more than that. – Joshua Taylor Jun 22 '15 at 14:31