Обсуждение: Problem with function that returns a cursor

Поиск
Список
Период
Сортировка

Problem with function that returns a cursor

От
Eduardo Muñoz
Дата:
I'm new to pgSQL and I'm having some trouble with a
function. I keep getting the following error:

org.postgresql.util.PSQLException: ERROR: cursor
"<unnamed portal 1>" does not exist

This is the function:

CREATE OR REPLACE FUNCTION ret_user(pusername
"varchar")
  RETURNS refcursor AS
$BODY$
DECLARE
    ccursor refcursor;
BEGIN
    open ccursor for
    select username,
        password,
        idrole
    from user
    where username = quote_literal($1);

    RETURN ccursor;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;


This is the JDBC code:

CallableStatement statement = null;
        ResultSet rs = null;
        Connection connection =
ConnectionPool.getConnection(saJNDI);
        try{
            statement = connection.prepareCall("{? =
call ret_user(?)");
            statement.registerOutParameter(1,
Types.OTHER);
            statement.setObject(2, "munoze");
            statement.execute();
            rs = (ResultSet)statement.getObject(1);
            while(rs.next()){
                System.out.println(rs.getString(1));
                System.out.println(rs.getString(2));
                System.out.println(rs.getString(3));
            }
            rs.close();
            statement.close();
        } catch(SQLException e){

        }

I hope you can help me



__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/

Re: Problem with function that returns a cursor

От
Michael Fuhr
Дата:
On Fri, Mar 03, 2006 at 11:06:20AM -0600, Eduardo Muñoz wrote:
> I'm new to pgSQL and I'm having some trouble with a
> function. I keep getting the following error:
>
> org.postgresql.util.PSQLException: ERROR: cursor
> "<unnamed portal 1>" does not exist

See my reply to your previous message about this:

http://archives.postgresql.org/pgsql-general/2006-03/msg00094.php

--
Michael Fuhr