mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
(agollapudi@demandsolutions.com). Also applied the RefCursor support patch by Nic Ferrier. This patch allows you too return a get a result set from a function that returns a refcursor. For example: call.registerOutParameter(1, Types.OTHER); call.execute(); ResultSet rs = (ResultSet) call.getObject(1); Modified Files: jdbc/org/postgresql/core/BaseStatement.java jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/jdbc1/Jdbc1CallableStatement.java jdbc/org/postgresql/jdbc1/Jdbc1PreparedStatement.java jdbc/org/postgresql/jdbc1/Jdbc1Statement.java jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java jdbc/org/postgresql/jdbc2/Jdbc2CallableStatement.java jdbc/org/postgresql/jdbc2/Jdbc2PreparedStatement.java jdbc/org/postgresql/jdbc2/Jdbc2Statement.java jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java jdbc/org/postgresql/jdbc3/Jdbc3PreparedStatement.java jdbc/org/postgresql/jdbc3/Jdbc3Statement.java Added Files: jdbc/org/postgresql/PGRefCursorResultSet.java jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java jdbc/org/postgresql/jdbc2/Jdbc2RefCursorResultSet.java jdbc/org/postgresql/jdbc3/Jdbc3RefCursorResultSet.java jdbc/org/postgresql/test/jdbc2/RefCursorTest.java
44 lines
1.3 KiB
Java
44 lines
1.3 KiB
Java
package org.postgresql.jdbc2;
|
|
|
|
|
|
import org.postgresql.core.QueryExecutor;
|
|
import org.postgresql.core.BaseStatement;
|
|
import org.postgresql.PGRefCursorResultSet;
|
|
|
|
|
|
/** A real result set based on a ref cursor.
|
|
*
|
|
* @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
|
|
*/
|
|
public class Jdbc2RefCursorResultSet extends Jdbc2ResultSet
|
|
implements PGRefCursorResultSet
|
|
{
|
|
|
|
String refCursorHandle;
|
|
|
|
// Indicates when the result set has activaly bound to the cursor.
|
|
boolean isInitialized = false;
|
|
|
|
Jdbc2RefCursorResultSet(BaseStatement statement, String refCursorName) throws java.sql.SQLException
|
|
{
|
|
super(statement, null, null, null, -1, 0L, false);
|
|
this.refCursorHandle = refCursorName;
|
|
}
|
|
|
|
public String getRefCursor ()
|
|
{
|
|
return refCursorHandle;
|
|
}
|
|
|
|
public boolean next () throws java.sql.SQLException
|
|
{
|
|
if (isInitialized)
|
|
return super.next();
|
|
// Initialize this res set with the rows from the cursor.
|
|
String[] toExec = { "FETCH ALL IN \"" + refCursorHandle + "\";" };
|
|
QueryExecutor.execute(toExec, new String[0], this);
|
|
isInitialized = true;
|
|
return super.next();
|
|
}
|
|
}
|