3 Replies Latest reply on Sep 8, 2010 12:31 PM by 771415

    Take the ID of a triple selected by SEM_MATCH

    771415
      Hi,

      I want to know the ID of some triple selected by SEM_MATCH.

      I thought of :

      select a.id
      from owltst a
      where a.triple.GET_SUBJECT() IN (
      SELECT sujet FROM TABLE(SEM_MATCH(
      '(?sujet ?propriete ?objet)',
      SEM_Models('owltstBIS_Model'),
      null, null, null)))

      But it doesn't work.

      Does someone have an idea?
        • 1. Re: Take the ID of a triple selected by SEM_MATCH
          715399
          Hi,

          I believe this is because get_subject() returns a URI wrapped with brackets, whereas SEM_MATCH returns it without any brackets. One way to solve this is to inspect the sujet$rdfvtyp column which is also returned by sem_match, and if it is a URI, then add the brackets to sujet. You can do this using a CASE statement.

          You also might want to look into the Jena Adapter, where this type of result set handling is done automatically.

          Cheers,
          Vlad
          • 2. Re: Take the ID of a triple selected by SEM_MATCH
            Sdas-Oracle
            You could try the following (it is also faster because it avoids a join with RDF_VALUE$):

            select a.id
            from owltst a
            where a.triple.rdf_s_id IN (
            SELECT sujet$rdfvid FROM TABLE(SEM_MATCH(
            '(?sujet ?propriete ?objet)',
            SEM_Models('owltstBIS_Model'),
            null, null, null)))

            If you want to use comparison using lexical values:

            select a.id
            from owltst a
            where a.triple.get_subject() IN (
            SELECT sem_apis.compose_rdf_term(sujet,sujet$rdfvtyp,sujet$rdfltyp,sujet$rdflang) FROM TABLE(SEM_MATCH(
            '(?sujet ?propriete ?objet)',
            SEM_Models('owltstBIS_Model'),
            null, null, null)))

            Thanks.
            1 person found this helpful
            • 3. Re: Take the ID of a triple selected by SEM_MATCH
              771415
              Hi,

              The request i wrote was juste an example. Your solution does'nt work if your sem_match selection refers to an objet, because a.triple.get_object() return's starts with "(CLOB) ".