Problem with function that returns a cursor - Mailing list pgsql-general

From Eduardo Muñoz
Subject Problem with function that returns a cursor
Date
Msg-id 20060303170620.66255.qmail@web36207.mail.mud.yahoo.com
Whole thread Raw
Responses Re: Problem with function that returns a cursor  (Michael Fuhr <mike@fuhr.org>)
List pgsql-general
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/

pgsql-general by date:

Previous
From: Alex
Date:
Subject: SELECT Question
Next
From: Scott Marlowe
Date:
Subject: Re: ERROR: column "datpath" does not exist