From: | Leo Martin Orfei <orfeileo(at)yahoo(dot)com> |
---|---|
To: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | funcion que retorne un resultset en java |
Date: | 2004-09-04 15:04:59 |
Message-ID: | 20040904150459.34201.qmail@web51803.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola.
Tengo un problema con las funciones de postgresql.
necesito hacer una funcion que me retorne un resulset
y poder recorrerlo desde java.
La funcion es bastante compleja pero el problema es
devolver el resultset.
supongamos la siguiente funcion:
create function test() returns catalog.refcursor as'
declare aux refcursor;
BEGIN
OPEN aux FOR SELECT nombre, direccion FROM tabla;
RETURN aux;
END;
'LANGUAGE 'plpgsql';
y el java:
CallableStatement cs = null;
ResultSet rs = null;
cs = con.prepareCall("{ ? = call test()}");
cs.registerOutParameter(1, java.sql.Types.OTHER);
rs = cs.executeQuery();
rs.next();
System.out.println("nombre: " +rs.getString(1));
pero me da el siguiente error:
cursor "<unnamed portal 1>" does not exist
Tambien probe esto:
Statement s = null;
rs = s.executeQuery("select test()");
rs.next();
System.out.println("nombre: " +rs.getString(1));
y si bien no falla, me da el siguiente resultado:
nombre: <unnamed portal 1>
Alguien me puede ayudar con esto?
Gracias.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Marques | 2004-09-04 15:11:40 | Re: Postgres para Solaris |
Previous Message | Alvaro Herrera | 2004-09-04 05:07:57 | Re: Datos entre Bases de Datos? |