Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-2418

Incompatible oracle sql method on collection.java (used by REST API)

    Details

    • Attachments:
      0
    • Comments:
      5
    • Documentation Status:
      Not Required

      Description

      When you use public ItemIterator getItems(Integer limit, Integer offset) from Collection.java and your database is Oracle, sql it is not properly for oracle because limit and offset does not exist.

      The solution is change the query:

      public ItemIterator getItems(Integer limit, Integer offset) throws SQLException
      {
      String myQuery ="";
      TableRowIterator rows =null;
      if(DatabaseManager.isOracle())

      { myQuery = "SELECT item_id,submitter_id,in_archive,withdrawn,discoverable,last_modified,owning_collection FROM " +"(SELECT item.*, ROWNUM as rnum FROM (SELECT item.* FROM item, collection2item WHERE " + "item.item_id=collection2item.item_id AND " + "collection2item.collection_id= ? " + "AND item.in_archive='1') item WHERE ROWNUM<=?) WHERE rnum > ?"; limit = limit + offset; rows = DatabaseManager.queryTable(ourContext,"item",myQuery,getID(), limit, offset); }

      else

      { myQuery = "SELECT item.* FROM item, collection2item WHERE " + "item.item_id=collection2item.item_id AND " + "collection2item.collection_id= ? " + "AND item.in_archive='1' limit ? offset ?"; rows = DatabaseManager.queryTable(ourContext, "item", myQuery,getID(), limit, offset); }

      return new ItemIterator(ourContext, rows);
      }

      Thanks!

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                helix84 Ivan Masár
                Reporter:
                rruiz Raul Ruiz
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: