I am wondering if I can use a user defined function in a user defined rule in oracle sem.. I've seen examples of user defined function used in sparql query filter clause in that dev. guide. However, I don't know if I can define a function in oracle sem. database and use it in the rule body or head. For example, I want to define a duration function that calculate the date difference between two dates. Then, I want to define a rule like this: event1 :has_start_date d1 and event1: has_end_date d2 and duration (24, d1,d2) then event1:date_satisfiable "yes". Does oracle support this kind of rule? Thank you very much.
The user defined rules are quite similar to a CONSTRUCT SPARQL query, where the FILTER clause is implemented in SQL.
I think we have already written rules like you want :
You have to write a PL/SQL FUNCTION that returns a NUMBER (not a BOOLEAN, think you are in SQL) :
FUNCTION DURATION(HOURS INTEGER, D1 VARCHAR2, D2 VARCHAR2) RETURN INTEGER
THEN RETURN 1;
ELSE RETURN 0;
Maybe you will have to GRANT EXECUTE ON DURATION TO MDSYS.
Then include the following in the FILTER clause of the Rulebase "[owner].duration (24, TO_CHAR(d1),TO_CHAR(d2)) = 1"
Hope this helps.