1 Reply Latest reply on Mar 9, 2007 6:27 PM by Mannamal-Oracle

    Example usage cursor

    502844
      Hello,
      Was wondering if I am writing a PL/SQL code and want to use cursors can I use it with the table returned by the sdo_rdf_match function.

      If yes,can some one please provide some sample code of usage or some url where its available.

      Thanks

      Regards

      Prateek
        • 1. Re: Example usage cursor
          Mannamal-Oracle
          Hi Prateek,

          Yes, that is possible. Here is an example using the data family demo example in the documentation. This finds the grandparents of Tom. Among various modifications possible one is to take in terms as arguments and use them in the SDO_RDF_MATCH query.

          create or replace procedure find_grandparents
          as
          type cur_typ is REF CURSOR;
          local_cursor cur_typ;
          ont_term varchar2(100);
          stmt varchar2(1000);

          begin

          stmt := 'SELECT x
          FROM TABLE(SDO_RDF_MATCH(
          ''(?x :grandParentOf :Tom)'',
          SDO_RDF_Models(''family''),
          SDO_RDF_Rulebases(''RDFS'',''family_rb''),
          SDO_RDF_Aliases(SDO_RDF_Alias('''',''http://www.example.org/family/'')),
          null))';

          open local_cursor for stmt;
          loop
          fetch local_cursor into ont_term;
          exit when local_cursor%NOTFOUND;
          dbms_output.put_line('grandparent is ' || ont_term);
          end loop;
          close local_cursor;


          end;
          /
          show errors;


          Melli