1 Reply Latest reply on May 18, 2009 2:17 PM by alwu-Oracle

    Update Triple...

    673499
      Hi...
      i want to update triple, how to do that in Oracle ?
      for example i have inserted triple

      INSERT INTO family_rdf_data VALUES (11,SDO_RDF_TRIPLE_S('family', 'http://www.example.org/family/Martha',
      'http://www.example.org/family/motherOf', 'http://www.example.org/family/Tom'));

      and... I want to update Tom becomes John?

      I just had one solution by updating that

      Object Triple :

      SDO_RDF_TRIPLE_S('family', 'http://www.example.org/family/Martha',
      'http://www.example.org/family/motherOf', 'http://www.example.org/family/Tom')

      with other Object Triple :

      SDO_RDF_TRIPLE_S('family', 'http://www.example.org/family/Martha',
      'http://www.example.org/family/motherOf', 'http://www.example.org/family/John')

      so it becomes like this

      Update family_rdf_data set TRIPLE = SDO_RDF_TRIPLE_S('family', 'http://www.example.org/family/Martha',
      'http://www.example.org/family/motherOf', 'http://www.example.org/family/John')
      Where Id = 11

      ......
      is there a way for not changing Object Triple but just changing attribute 'object' of SDO_RDF_TRIPLES_S ?
      Sorry for my poor eNglish...

      Thanks
        • 1. Re: Update Triple...
          alwu-Oracle
          What you wrote is a good way to update the triple.

          If you happen to know the IDs for those URI/bNode/literals, then you can try something as follows. Keep in mind that those IDs are not guaranteed to be fixed.


          create table np (triple sdo_rdf_triple_s);
          exec sem_apis.create_sem_model('np','np','triple');

          insert into np values(sdo_rdf_triple_s('np','<urn:x>', '<urn:p>', '<urn:y>'));
          insert into np values(sdo_rdf_triple_s('np','<urn:x>', '<urn:p>', '<urn:z>'));

          set numwidth 20
          set line 160

          SQL> list
          1* select * from np
          SQL> /

          TRIPLE(RDF_C_ID, RDF_M_ID, RDF_S_ID, RDF_P_ID, RDF_O_ID)
          ----------------------------------------------------------------------------------------------------------------------------------------------------------------
          SDO_RDF_TRIPLE_S(5157658052632356926, 1, 6354524810780932050, 2812185635207236178, 5157658052632356926)
          SDO_RDF_TRIPLE_S(967934890940996329, 1, 6354524810780932050, 2812185635207236178, 967934890940996329)


          SQL> select count(1) from np;
          COUNT(1)
          --------------------
          2

          SQL> select count(1) from mdsys.semm_np;
          COUNT(1)
          --------------------
          2

          ---
          --- Now, lets replace the '<urn:z>' with '<urn:y>'
          ---
          update np t set t.triple.rdf_o_id=5157658052632356926
          , t.triple.rdf_c_id=5157658052632356926
          where t.triple.rdf_m_id=1
          and t.triple.rdf_s_id=6354524810780932050
          and t.triple.rdf_p_id=2812185635207236178
          and t.triple.rdf_c_id=967934890940996329;

          SQL> select count(1) from mdsys.semm_np;
          COUNT(1)
          --------------------
          1

          SQL> select cost from mdsys.semm_np;
          COST
          --------------------
          2

          select s, p, o from table(sem_match('(?s ?p ?o)', sem_models('np'), null, null, null));
          SQL>
          S
          ----------------------------------------------------------------------------------------------------------------------------------------------------------------
          P
          ----------------------------------------------------------------------------------------------------------------------------------------------------------------
          O
          ----------------------------------------------------------------------------------------------------------------------------------------------------------------
          urn:x
          urn:p
          urn:y