Aggregate functions in Rules?

I am trying to get the max ID and add 1 to it in order to create a new ID for employees who were inserted into the DB without an ID. But my bind fails and returns an internal server error.

[] a rule:SPARQLRule;
rule:content """
prefix carnot: <> 

IF {
  ?e a carnot:Employee .
  ?e carnot:ID ?id .
  BIND((max(?id)+1) as ?newID) .
  #Filter not exists {?e carnot:ID ?i} 
    ?e carnot:ID ?newID

I don’t think that aggregates are allowed in rules. From the documentation section “gotchas and limitations” at the end of #3 “Other SPARQL features are not allowed in rules.” whichI believe includes aggregations.

I wanted to add something a little bit more helpful than, “you can’t do that”, you might want to try using stardog integrity constraints (ICV). That would at least keep you from inserting Employee’s without supplying an id.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.