title: How to access the procedure that return setof refcursor from PostgreSQL in Java?
body: <p>Need to access a procedure that return setof refcursor from PostgreSQL.</p>
  
  <p>I am able to access the first object but not rest of object not rest of objects.</p>
  
  <pre><code>    con.setAutoCommit(false);
      try (CallableStatement proc = 
               con.prepareCall("{ ? = call usp_sel_article_initialdata_new1() }")) {
          proc.registerOutParameter(1, Types.OTHER);
          proc.execute();
          ResultSet results = (ResultSet) proc.getObject(1); 
          while (results.next()) {
              System.out.println("Result Id" + results.getString(1));
              System.out.println("Results Name" + results.getString(2));
      }
  </code></pre>
  
  <p>This give me the first refcursor values but when i try to use second refcursor it give me error
  I use this line:  </p>
  
  <pre><code>proc.registerOutParameter(2, Types.OTHER);
  </code></pre>
  
  <p>It is giving errors . Also tried:</p>
  
  <pre><code>proc.registerOutParameter(1, Types.REF);
  </code></pre>
  
  <p>This also not work.
  Procedure Example is:</p>
  
  <pre><code>    CREATE OR REPLACE FUNCTION usp_sel_article_initialdata_new1()
      RETURNS SETOF refcursor AS
      $BODY$
      Declare swv_refcur refcursor;
      swv_refcur2 refcursor;
      DECLARE r record;
      BEGIN
  
      open SWV_RefCur for Select OM.opID as ID,OM.OperatorName as Name from operator
      AS OM (OPid bigint,OperatorName character varying(100),status boolean)
      where OM.status = true 
      order By OperatorName;
      return next SWV_RefCur;
  
      open SWV_RefCur2 for Select CC.cirid as ID,CC.cirnm as Name from  circle 
      AS CC (cirid bigint,cirnm character varying(100),status boolean)
      where Status = true and cirid not in(28,31) 
      order by cirnm;
      return next SWV_RefCur2;
  </code></pre>
  
  <p>Please help me how to access second object.</p>