1 Reply Latest reply on Sep 15, 2020 2:18 AM by MaxOrgiyan-Oracle

    Fecth document from multiple Collections SODA oracle 19C

    4313552

      Hi All,

       

      How to fetch document from multiple Collections in SODA oracle 19 C ?

        • 1. Re: Fecth document from multiple Collections SODA oracle 19C
          MaxOrgiyan-Oracle

          Just open each collection, and fetch the documents from it.

           

          For example:

           

          OracleDatabase db = ...

           

          // Open the first collection

          OracleCollection col1 = db.openCollection("myFirstCollectionNameHere");

           

          // Open the second collection

          OracleCollection col2 = db.openCollection("mySecondCollectionNameHere");

           

          // Get the documents from the first collection. filter(...) is just an example - this will get the documents matching a QBE.

          // You could alternatively use key(...) or keys(...), to fetch documents by their keys.

          OracleCursor c1 = col1.find().filter(...).getCursor();

          while (c1.hasNext())

              OracleDocument doc = c1.next();

           

          // Very important: close the cursor

          c1.close();

           

          // Get the documents from the second collection.

          OracleCursor c2 = col2.find().filter(...).getCursor();

          while (c2.hasNext())

              OracleDocument doc = c2.next();

          c2.close();

           

          Does this code snippet answer your question or do you need a full runnable example?