Problem with Function

From: Eduardo Muñoz <eduardomc_79(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Problem with Function
Date: 2006-03-02 21:18:14
Message-ID: 20060302211814.52616.qmail@web36212.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, I'm new with pgSQL and I'm not sure why, but I
keep getting the same error. I want to call a function
that returns a cursor and I keep getting the following
exception:

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

I would appreciate any help with this problem.

This is my JDBC code:

Connection objlConnection =
ConnectionPool.getConnection(saJNDI);
CallableStatement statement = null;
ResultSet rs = null;
try{
statement = objlConnection.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 (SQLExcepton e){
...

This is my function code:

CREATE OR REPLACE FUNCTION
traer_usuario(pnombreusuario "varchar")
RETURNS refcursor AS
$BODY$
DECLARE
ccursor refcursor;
BEGIN
open ccursor for
select nombreusuario,
contrasena,
idrol
from usuario
where nombreusuario = quote_literal($1);

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

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-03-02 21:38:59 Re: Problem with Function
Previous Message Oisin Glynn 2006-03-02 20:45:01 [Fwd: Schema Question]