hi,
i am defining precision on a dataproperty using this statement :
PREFIX xsd: http://www.w3.org/2001/XMLSchema#
PREFIX ex: http://example.com/
CREATE PROPERTY ex:sales
rdf:type owl:DatatypeProperty ;
rdfs:range xsd:decimal ;
ex:decimalPrecision “2”^^xsd:integer .
SPARQL SELECT ?product ?sales ?revenue WHERE {
?product ex:sales ?sales . ?product ex:revenue ?revenue . }
?sales or avg.sum on sales will always return 2 decimal values as virtuoso internally
will use the decimalPrecision definition before returning value.
?revenue will come as rawvalue as stored as no precision definition for it.
Is default virtuoso opensource 7 will work same way ?
if not then what is option to make that work ?
Thanks in advance,
nyadav
Your problem description is not clear, what is the CREATE PROPERTY
construct which does not look valid ?
Do you have a runnable test case against a Virtuoso instance that can be used to recreate the issue being reported ?
yes, looks like i got wrong suggestion from web.
basically my usecase is :
sales rdf:type owl:DatatypeProperty
rdfs:range xsd:decimal
for sales dataproperty i want to define precision of two decimals then in select queries
expecting virtuoso always return values in two decimal for sales…
revenue will return raw values as no precision requirement.
Please suggest correct way to solve this usecase?
Thanks,
nyadav
The Virtuoso round function can be used to return values with precision of two:
SQL> sparql select (ROUND(?number*100)/100 AS ?round) where { values (?number) { (12345.67890) } };
round
LONG VARCHAR
_______________________________________________________________________________
12345.68
1 Rows. -- 4 msec.
SQL>
SPARQL solution link
thanks for suggestion…
Is same possible without making changes in existing sparql queries ?
Like as we say rdfs:range xsd:decimal,
similar way define decimalprecision for dataproperties, if possible.
then virtuoso internally take care of returning values as per precision
without any change in queries ?
Thanks,
nyadav