title: Getting ERROR: cursor "<unnamed portal 1>" does not exist
body: <p>Im trying to use SimpleJdbcCall from spring.jdbc calling function that return a cursor and im getting following error:</p>
  
  <pre><code>org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call dbo.api_config_select(?)}]; SQL state [34000]; error code [0]; ERROR: cursor "&lt;unnamed portal 1&gt;" does not exist; nested exception is org.postgresql.util.PSQLException: ERROR: cursor "&lt;unnamed portal 1&gt;" does not exist
  </code></pre>
  
  <p>This is PostGreSQL function code:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION "dbo"."api_config_select" (in "_id" integer) RETURNS refcursor AS
  $$
      DECLARE
        ref refcursor;                                                     
      BEGIN
        OPEN ref FOR 
  
          SELECT
              1;
  
        RETURN ref;                                                       
      END;
      $$
  LANGUAGE 'plpgsql' COST 100
  </code></pre>
  
  <p>and this is Java code</p>
  
  <pre><code>        simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate).withFunctionName("api_config_select").withSchemaName("dbo")
                .declareParameters(
  
                new SqlOutParameter("_cursor",  Types.OTHER),
                new SqlParameter("_id", Types.INTEGER));
  
          HashMap&lt;String, Object&gt; params = new HashMap&lt;String, Object&gt;();
          params.put("_id", id);
  
          try {
              Map&lt;String, Object&gt; result = simpleJdbcCall.execute(10);
              for (String s : result.keySet()) {
                  System.out.println("6.0  " + result.get(s));
              }
          }
  
          catch(UncategorizedSQLException e) {
              e.printStackTrace();
          }
          catch(Exception e) {
                  e.printStackTrace();
          }
  </code></pre>
  
  <p>As soon as app call simpleJdbcCall.execute() im getting error. I tried to pass refcursor name, but getting same error.</p>
  
  <p>Anyone have code sample code of using PostgreSql, Spring JDBC and cursor?</p>