user3358377
user3358377

Reputation: 145

SPARQL insert query

In turtle I have something like this:

@prefix b: <http://www.fake.org/vl/> .

b:ID_13 b:OwnBy b:Katrin ;
    b:Rank   "5" .

b:FID_13 b:OwnBy b:emily ;
    b:Rank "9" ;
    b:Comment "comment \"George goes to school!" ;
    b:Time_Comment "at 10:18 21/01/2015" .

when I use

SELECT * WHERE{

    ?ID  b:OwnBy  ?Name;
         b:Rank     ?Rank;
}

I get as result

ID       Name     Rank
ID_13   Katrin    "5"
ID_13   emily     "9"

How can I INSERT another rank for ID_13 Katrin (Only for katrin) ????

I have tried this

INSERT {b:ID_13 b:Rank  "pppppppppppppp"}

WHERE{b:ID_13 b:OwnBy b:Cathy}

But when I use select to see what I have inserted, this query inserts the new rank to both, Katring and emily and then I have the following result:

ID       Name     Rank
ID_13   Katrin    "5"
ID_13   Katrin    "pppppppp"
ID_13   emily     "9"
ID_13   emily     "pppppppp"

Upvotes: 0

Views: 485

Answers (1)

Jeen Broekstra
Jeen Broekstra

Reputation: 22042

Your example data contains two triples with the property b:OwnBy:

  b:ID_13 b:OwnBy b:Katrin .
  b:ID_13 b:OwnBy b:emily .

(I am assuming that the b:FID_13 in your question is a typo)

Note that both triples share the same subject. Therefore, the resource denoted by b:ID_13 is owned by both Katrin and emily.

Your INSERT operation tries to add a triple b:ID_13 b:Rank "pppppppppppppp". The WHERE clause makes no sense as there are no variables to fill in this pattern - it is not precisely wrong, but it doesn't really do anything useful. That aside, what you want to do is simply a logical impossibility. Since b:ID_13 is a shared subject for both owners Katrin and emily, you can not insert a rank for b:ID_13 that does not automatically apply to both Katrin and emily.

The fault is not your INSERT operation, but your input data. You need to make sure that the resources owned by Katrin and emily do not share the same subject identifier.

Upvotes: 2

Related Questions