aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java')
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java
new file mode 100644
index 00000000000..7b83bf67427
--- /dev/null
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java
@@ -0,0 +1,44 @@
+package org.postgresql.jdbc1;
+
+import java.sql.SQLException;
+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 Jdbc1RefCursorResultSet extends Jdbc1ResultSet
+ implements PGRefCursorResultSet
+{
+
+ // The name of the cursor being used.
+ String refCursorHandle;
+
+ // Indicates when the result set has activaly bound to the cursor.
+ boolean isInitialized = false;
+
+
+ Jdbc1RefCursorResultSet(BaseStatement statement, String refCursorName)
+ {
+ super(statement, null, null, null, -1, 0L, false);
+ this.refCursorHandle = refCursorName;
+ }
+
+ public String getRefCursor ()
+ {
+ return refCursorHandle;
+ }
+
+ public boolean next () throws 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();
+ }
+}