Search Postgresql Archives

Problem with function that returns a cursor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/ 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux