From: brian z. <bz...@us...> - 2001-12-04 03:09:47
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql/handler In directory usw-pr-cvs1:/tmp/cvs-serv28814/ziclix/python/sql/handler Modified Files: InformixDataHandler.java MySQLDataHandler.java PostgresqlDataHandler.java Log Message: added .rowid to PyCursor and .getRowId(Statement) to DataHandlers Index: InformixDataHandler.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/handler/InformixDataHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InformixDataHandler.java 2001/11/20 04:55:18 1.1 --- InformixDataHandler.java 2001/12/04 03:09:44 1.2 *************** *** 25,31 **** public class InformixDataHandler extends FilterDataHandler { - /** Field serial */ - public int serial; - /** * Decorator for handling Informix specific issues. --- 25,28 ---- *************** *** 34,53 **** */ public InformixDataHandler(DataHandler datahandler) { - super(datahandler); - - this.serial = 0; } /** ! * Sets the serial attribute to the last serial id. */ ! public void postExecute(Statement stmt) throws SQLException { if (stmt instanceof com.informix.jdbc.IfmxStatement) { ! serial = ((com.informix.jdbc.IfmxStatement)stmt).getSerial(); } ! super.postExecute(stmt); } --- 31,54 ---- */ public InformixDataHandler(DataHandler datahandler) { super(datahandler); } /** ! * Returns the serial for the statement. ! * ! * @param Statement stmt ! * ! * @return PyObject ! * ! * @throws SQLException ! * */ ! public PyObject getRowId(Statement stmt) throws SQLException { if (stmt instanceof com.informix.jdbc.IfmxStatement) { ! return Py.newInteger(((com.informix.jdbc.IfmxStatement)stmt).getSerial()); } ! return super.getRowId(stmt); } Index: MySQLDataHandler.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/handler/MySQLDataHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MySQLDataHandler.java 2001/11/20 04:55:18 1.1 --- MySQLDataHandler.java 2001/12/04 03:09:45 1.2 *************** *** 24,30 **** public class MySQLDataHandler extends FilterDataHandler { - /** Field lastInsertId */ - public long lastInsertId; - /** * Decorator for handling MySql specific issues. --- 24,27 ---- *************** *** 33,52 **** */ public MySQLDataHandler(DataHandler datahandler) { - super(datahandler); - - this.lastInsertId = 0; } /** ! * Captures the last inserted id. */ ! public void postExecute(Statement stmt) throws SQLException { if (stmt instanceof org.gjt.mm.mysql.Statement) { ! lastInsertId = ((org.gjt.mm.mysql.Statement)stmt).getLastInsertID(); } ! super.postExecute(stmt); } --- 30,53 ---- */ public MySQLDataHandler(DataHandler datahandler) { super(datahandler); } /** ! * Returns the last insert id for the statement. ! * ! * @param Statement stmt ! * ! * @return PyObject ! * ! * @throws SQLException ! * */ ! public PyObject getRowId(Statement stmt) throws SQLException { if (stmt instanceof org.gjt.mm.mysql.Statement) { ! return Py.newInteger(((org.gjt.mm.mysql.Statement)stmt).getLastInsertID()); } ! return super.getRowId(stmt); } Index: PostgresqlDataHandler.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/handler/PostgresqlDataHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PostgresqlDataHandler.java 2001/11/20 04:55:18 1.1 --- PostgresqlDataHandler.java 2001/12/04 03:09:45 1.2 *************** *** 14,17 **** --- 14,18 ---- import java.sql.SQLException; import java.sql.PreparedStatement; + import java.sql.Statement; import java.math.BigDecimal; import org.python.core.*; *************** *** 34,37 **** --- 35,57 ---- public PostgresqlDataHandler(DataHandler datahandler) { super(datahandler); + } + + /** + * Returns the last insert OID for the statement. + * + * @param Statement stmt + * + * @return PyObject + * + * @throws SQLException + * + */ + public PyObject getRowId(Statement stmt) throws SQLException { + + if (stmt instanceof org.postgresql.Statement) { + return Py.newInteger(((org.postgresql.Statement)stmt).getInsertedOID()); + } + + return super.getRowId(stmt); } |