Knowing if an INSERT has been successful

1 view
Skip to first unread message

justforthe...@gmail.com

unread,
Jun 9, 2016, 6:10:29 PM6/9/16
to Stardog
Hi all,

Is there a way to know if an INSERT query has been successful or not?  I am executing both via Web GUI and via Java and not getting any errors (result = true in the GUI). However, the data are not saved, and I can't find the mistake.


This is a reduced version of the query (which doesn't succeed either):

INSERT { ?idd a ?type, owl:NamedIndividual .
        ?idd ex:name ?newname .        
        ?idd rdfs:label ?newname .    
       } 
WHERE {  BIND(?id AS ?idd)
         BIND(?classiri AS ?type) 
         BIND(?name AS ?newname) 
      }
# Overrides by the API: 
# PARAMETERS ( ?name ?id ?classiri ) {
# "Eeee"
# }

Thanks!

Pavel Klinov

unread,
Jun 10, 2016, 3:46:01 AM6/10/16
to sta...@clarkparsia.com
If the API call for the update completed without exceptions and returned true, the update has been successful. Can you provide a minimal complete code example where you run the update, then check for the changes and they aren't there?

Best,
Pavel

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Evren Sirin

unread,
Jun 10, 2016, 8:56:49 AM6/10/16
to Stardog
It might not be the issue but I see your parameters might have a typo:
classiri is http:/ex.com/d#Document, note the missing slash after
http.

Best,
Evren

Zachary Whitley

unread,
Jun 10, 2016, 10:23:46 AM6/10/16
to Stardog
I tried it with the fixed typo and didn't get any results either but I did get a warning in the logs
 (Stardog 4.1)

$> stardog db create -n test
$> stardog query execute -b "name=\"Eeee\" id=<http://ex.com/d#document_970> classiri=<http://ex.com/d#Document>" -u admin -P test "prefix ex: <htttp://ex.com/> INSERT { ?idd a ?type, owl:NamedIndividual .

        ?idd ex:name ?newname .       
        ?idd rdfs:label ?newname .   
       }
WHERE {  BIND(?id AS ?idd)
         BIND(?classiri AS ?type)
         BIND(?name AS ?newname)
      }

$> stardog data export test -u admin -P

@prefix : <http://api.stardog.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix stardog: <tag:stardog:api:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


$> tail stardog.log

WARN  2016-06-10 10:08:11,621 [Stardog.Executor-2123] com.complexible.stardog.plan.eval.operator.impl.ModifyOperatorImpl:varType(459): Cannot determine the type of the variable in the update query: context
WARN  2016-06-10 10:11:42,869 [Stardog.Executor-2141] com.complexible.stardog.plan.eval.operator.impl.ModifyOperatorImpl:varType(459): Cannot determine the type of the variable in the update query: context

I tried the equivalent construct query and it doesn't return any results


$> stardog query execute -b "name=\"Eeee\" id=<http://ex.com/d#document_970> classiri=<http://ex.com/d#Document>" -u admin -P test "prefix ex: <htttp://ex.com/> CONSTRUCT  { ?idd a ?type, owl:NamedIndividual .

        ?idd ex:name ?newname .       
        ?idd rdfs:label ?newname .   
       }
WHERE {  BIND(?id AS ?idd)
         BIND(?classiri AS ?type)
         BIND(?name AS ?newname)
      }"


@prefix : <http://api.stardog.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix stardog: <tag:stardog:api:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


While looking at the man page I noticed a small typo

$> stardog help query execute

...

        * Execute a query with some specified bindings:
            $ stardog query -b "s=<http://example.org/test>" p=ex:name o=\"John Doe\"' myDb "select * {?s ?p ?o}"

There's an unbalanced quote. I believe that the trailing single quote \"John Doe\"' should be a double quote \"John Doe\"". Or I guess you could make the beginning double quote "s= a single quote 's= and not escape the enclosed double quotes.

...



You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.


Martynas Jusevičius

unread,
Jun 10, 2016, 10:57:10 AM6/10/16
to sta...@clarkparsia.com
I think some triplestores return <boolean>true</boolean> (as in ASK
result), if the update was successful; <boolean>false</boolean>
otherwise.
> ---

Evren Sirin

unread,
Jun 10, 2016, 11:21:16 AM6/10/16
to Stardog
Zachary,

There is an error in your command. When you wrap all bindings between
a single pair of quotations it is interpreted as a single binding. See
the explain output:

$ sstaridg query explain -b name="\"Eeee\"
-- test query.sparql
Explaining Query:

prefix ex:<http://ex.com/> INSERT { ?idd a ?type, owl:NamedIndividual .
?idd ex:name ?newname .
?idd rdfs:label ?newname .
}
WHERE { BIND(?id AS ?idd)
BIND(?classiri AS ?type)
BIND(?name AS ?newname)
}
# Overrides by the API:
# PARAMETERS ( ?name ) {
# "Eeee"
# }

Since parameters are not bound nothing is inserted but this is still a
successful operation because there were no errors. Use quotations to
escape characters that would otherwise be executed by the shell. The
following version works fine and updates the database:

$ stardog query explain -b name=\"Eeee\"
id="<http://ex.com/d#document_970>"
classiri="<http://ex.com/d#Document>" -- test query.sparql

prefix ex:<http://ex.com/> INSERT { ?idd a ?type, owl:NamedIndividual .
?idd ex:name ?newname .
?idd rdfs:label ?newname .
}
WHERE { BIND(?id AS ?idd)
BIND(?classiri AS ?type)
BIND(?name AS ?newname)
}
# Overrides by the API:
# PARAMETERS ( ?name ?id ?classiri ) {
# "Eeee"
# <http://ex.com/d#document_970>
# <http://ex.com/d#Document>
# }

BTW, I didn't mean the typo in the URL would cause the query to fail
but would insert different triples than expected so one might think
database is not updated.

Best,
Evren

Zachary Whitley

unread,
Jun 10, 2016, 11:32:59 AM6/10/16
to Stardog
Thanks. I was a little confused about how the parameters where expected to be quoted after looking at the help page. I said there was a typo on the man page but I meant the help page from

$> stardog help query execute

Evren Sirin

unread,
Jun 10, 2016, 11:59:27 AM6/10/16
to Stardog
On Fri, Jun 10, 2016 at 11:32 AM, Zachary Whitley
<zachary...@wavestrike.com> wrote:
> Thanks. I was a little confused about how the parameters where expected to
> be quoted after looking at the help page. I said there was a typo on the man
> page but I meant the help page from
>
> $> stardog help query execute

Yes, the dangling single quote in the example is wrong. fixed it now.

Thanks,

Jeremy Iron

unread,
Jun 10, 2016, 1:47:06 PM6/10/16
to stardog
Thank you all for the answers. I am doing further testing because the real query is a bit long and uses multiple values coming from a form that I have to check. I found however that the limited query I published didn't work due to a typo (not the missing slash, that was my mistake when I edited it). If I cannot find the solution after my testing I will update this conversation with a more detailed example and a minimal complete code example as suggested. Have a good weekend.

 

You received this message because you are subscribed to a topic in the Google Groups "Stardog" group.
To unsubscribe from this topic, visit https://groups.google.com/a/clarkparsia.com/d/topic/stardog/a3yshdqOip0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stardog+u...@clarkparsia.com.


Reply all
Reply to author
Forward
0 new messages