From: Jerven B. <jer...@is...> - 2013-05-15 15:28:04
|
Hi Vishesh, Wouldn't the following work? WITH <nepomuk:/ctx/graph> DELETE { <resA> nao:lastModified ?mod . } INSERT { <resA> nao:lastModified "2012-01-29T16:29:11Z"^^xsd:dateTime . } WHERE { OPTIONAL {<resA> nao:lastModified ?mod .} } The first example you posted would not match in the case where the <resA> nao:lastModified ?mod did not yet exist. This form should match the update or insert behavior you are looking for. But I might be wrong not using update day to day. Regards, Jerven On 15/05/13 17:20, Vishesh Handa wrote: > Hey Ivan > > On Tue, May 14, 2013 at 8:44 PM, Ivan Mikhailov > <imi...@op...> wrote: >> Hello Vishesh, >> >> The query says: >> >> For every triple <resA> nao:lastModified ?mod found in database (if >> any), >> >> prepare future removal of <resA> nao:lastModified ?mod >> and >> prepare insertion of <resA> nao:lastModified >> "2012-01-29T16:29:11Z"^^xsd:dateTime . >> >> When all (if any) operations are prepared, perform the actual edition of >> the database. >> >> No <resA> nao:lastModified ?mod at the very beginning --- no >> manipulations prepared --- no effect. >> >> The solution is to make separate DELETE and then an unconditional >> INSERT. > > Thanks for the detailed explanation. I was hoping to optimize it by > not having to call a separate delete and insert operation. > > It would be nice to have something like an 'update or insert' like one > has in SQL. > >> >> Best Regards, >> >> Ivan Mikhailov >> OpenLink Software >> http://virtuoso.openlinksw.com >> >> On Tue, 2013-05-14 at 15:27 +0530, Vishesh Handa wrote: >>> Hey guys >>> >>> I've been trying to update some statements in a graph, and I have been >>> using the following query - >>> >>> WITH <nepomuk:/ctx/graph> >>> DELETE { <resA> nao:lastModified ?mod . } >>> INSERT { <resA> nao:lastModified "2012-01-29T16:29:11Z"^^xsd:dateTime . } >>> WHERE { <resA> nao:lastModified ?mod . } >>> >>> This works fine in the case when the <resA> nao:lastModified ?m triple >>> already exists, but it does not insert the new statement if that >>> triple does not exist. >>> >>> I was checking the SPARQL 1.1 Update Standard [1], and I found the >>> following text - >>> >>> "Deleting triples that are not present, or from a graph that is not >>> present will have no effect and will result in success." >>> >>> So in the case when the triple is not present the delete operation >>> should result in a success and the insert operation should be carried >>> out. But that does not seem to be the case. >>> >>> Could someone please confirm if this is just a bug or is that the >>> intended behaviour? >>> >>> [1] http://www.w3.org/TR/2012/PR-sparql11-update-20121108/#deleteInsert >>> >>> -- >>> Vishesh Handa >>> >>> ------------------------------------------------------------------------------ >>> AlienVault Unified Security Management (USM) platform delivers complete >>> security visibility with the essential security capabilities. Easily and >>> efficiently configure, manage, and operate all of your security controls >>> from a single console and one unified framework. Download a free trial. >>> http://p.sf.net/sfu/alienvault_d2d >>> _______________________________________________ >>> Virtuoso-users mailing list >>> Vir...@li... >>> https://lists.sourceforge.net/lists/listinfo/virtuoso-users >> > > > > -- > Vishesh Handa > > ------------------------------------------------------------------------------ > AlienVault Unified Security Management (USM) platform delivers complete > security visibility with the essential security capabilities. Easily and > efficiently configure, manage, and operate all of your security controls > from a single console and one unified framework. Download a free trial. > http://p.sf.net/sfu/alienvault_d2d > _______________________________________________ > Virtuoso-users mailing list > Vir...@li... > https://lists.sourceforge.net/lists/listinfo/virtuoso-users > -- ------------------------------------------------------------------- Jerven Bolleman Jer...@is... SIB Swiss Institute of Bioinformatics Tel: +41 (0)22 379 58 85 CMU, rue Michel Servet 1 Fax: +41 (0)22 379 58 58 1211 Geneve 4, Switzerland www.isb-sib.ch - www.uniprot.org Follow us at https://twitter.com/#!/uniprot ------------------------------------------------------------------- |