]> granicus.if.org Git - postgresql/blobdiff - src/interfaces/jdbc/org/postgresql/jdbc2/Statement.java
Tue Jan 30 22:24:00 GMT 2001 peter@retep.org.uk
[postgresql] / src / interfaces / jdbc / org / postgresql / jdbc2 / Statement.java
index 04315c096a16206ca027f0f71b34f0e1cf8879d0..a0a40c146955cbcdd066e2195b9da7fa5acb98c3 100644 (file)
@@ -32,6 +32,7 @@ public class Statement implements java.sql.Statement
     private Vector batch=null;
     int resultsettype;                // the resultset type to return
     int concurrency;         // is it updateable or not?
+    int maxrows=0;            // the maximum number of rows to return 0=unlimited
 
        /**
         * Constructor for a Statement.  It simply sets the connection
@@ -134,7 +135,7 @@ public class Statement implements java.sql.Statement
         */
        public int getMaxRows() throws SQLException
        {
-               return connection.maxrows;
+               return maxrows;
        }
 
        /**
@@ -146,7 +147,7 @@ public class Statement implements java.sql.Statement
         */
        public void setMaxRows(int max) throws SQLException
        {
-         connection.maxrows = max;
+         maxrows = max;
        }
 
        /**
@@ -274,7 +275,8 @@ public class Statement implements java.sql.Statement
        if(escapeProcessing)
            sql=connection.EscapeSQL(sql);
 
-       result = connection.ExecSQL(sql);
+        // New in 7.1, pass Statement so that ExecSQL can customise to it
+       result = connection.ExecSQL(sql,this);
 
         // New in 7.1, required for ResultSet.getStatement() to work
         ((org.postgresql.jdbc2.ResultSet)result).setStatement(this);
@@ -388,11 +390,6 @@ public class Statement implements java.sql.Statement
        throw org.postgresql.Driver.notImplemented();
     }
 
-    //public int getKeysetSize() throws SQLException
-    //{
-//     throw org.postgresql.Driver.notImplemented();
-    //}
-
     public int getResultSetConcurrency() throws SQLException
     {
       // new in 7.1
@@ -415,11 +412,6 @@ public class Statement implements java.sql.Statement
        throw org.postgresql.Driver.notImplemented();
     }
 
-    //public void setKeysetSize(int keys) throws SQLException
-    //{
-//     throw org.postgresql.Driver.notImplemented();
-    //}
-
     public void setResultSetConcurrency(int value) throws SQLException
     {
       concurrency=value;
@@ -430,4 +422,17 @@ public class Statement implements java.sql.Statement
       resultsettype=value;
     }
 
+    /**
+     * New in 7.1: Returns the Last inserted oid. This should be used, rather
+     * than the old method using getResultSet, which for executeUpdate returns
+     * null.
+     * @return OID of last insert
+     */
+    public int getInsertedOID() throws SQLException
+    {
+      if(result!=null)
+        return ((org.postgresql.ResultSet)result).getInsertedOID();
+      return 0;
+    }
+
 }