3 Replies Latest reply on Aug 12, 2015 5:33 PM by alwu-Oracle

    Removing a single statement without using jena or sesame

    jerven

      How does one remove a single triple/quad from a SEM_MODEL without using jena or sesame?

      Or is it possible to use SPARUL inside sqldeveloper/sqlplus?

        • 1. Re: Removing a single statement without using jena or sesame
          alwu-Oracle

          Hi,

           

          Here is an example PL/SQL code snippet (declared in a Java string) that might be useful. You will need to pass in model name (and graph name), subject, predicate, and object. Note that it assumes that you have an index on the application table. Given that you want to remove a single triple, it is important to have an index on the application table. There is an API  graphOracleSem.rebuildApplicationTableIndex in Jena Adapter that you can call to create it (if absent)

           

              String szStmt =
                 "DECLARE "
               + "  tid    varchar2(1000); "
               + "  val    varchar2(1000); "
               + "BEGIN "
               + "  tid := sdo_rdf.GET_TRIPLE_ID( ?, ?, ?, ? ); "
               + "  val := tid; "
               + "  "
               + "  delete /*+ index(app " + indexName + ") */ "
               + "  from " + tableName + " app "
               + "  where "
               + " bitand(app." + colName + ".rdf_m_id,79228162514264337593543950335-4294967295) / 4294967296 = "
               + "   (CASE when instr(val,'g') = 0 "
               + "    then 0 "
               + "    else sys_op_rawtonum(substr(val,instr(val,'g')+1, instr(val,'_') - instr(val,'g') - 1)) "
               + "    END) and "
               + " (app." + colName + ".rdf_s_id) = sys_op_rawtonum(substr(val,instr(val,'_')+1, instr(val,'_',instr(val,'_')+1) - instr(val,'_') -1) ) and "
               + " (app." + colName + ".rdf_p_id) = sys_op_rawtonum(substr(val,instr(val,'_',1,2)+1, instr(val,'_',1,3) - instr(val,'_',1,2)-1) ) and "
               + " (app." + colName + ".rdf_c_id) = sys_op_rawtonum(substr(val,instr(val,'_',1,3)+1, length(val) - instr(val,'_',1,3)) ); "
               + "  ? := SQL%ROWCOUNT; "
               + "END; ";
          
          

           

          Hope it helps,

           

          Zhe Wu

          • 2. Re: Removing a single statement without using jena or sesame
            jerven

            I was worried this was going to be the answer... Its fine for now but a function in the sem_apis would be appreciated in the future.

            • 3. Re: Removing a single statement without using jena or sesame
              alwu-Oracle

              Hi,

               

              That is a good suggestion. I will log an enhancement request.

               

              Thanks,


              Zhe Wu