From: brian z. <bz...@us...> - 2002-05-10 16:11:44
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql In directory usw-pr-cvs1:/tmp/cvs-serv25484/com/ziclix/python/sql Modified Files: PyCursor.java PyConnection.java Procedure.java DataHandler.java Log Message: extensible stored procedures Index: PyCursor.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/PyCursor.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PyCursor.java 9 May 2002 21:44:29 -0000 1.26 --- PyCursor.java 10 May 2002 16:11:41 -0000 1.27 *************** *** 461,465 **** } ! final Procedure procedure = new Procedure(this, name); Statement stmt = procedure.prepareCall(this.rsType, this.rsConcur); --- 461,465 ---- } ! final Procedure procedure = datahandler.getProcedure(this, name); Statement stmt = procedure.prepareCall(this.rsType, this.rsConcur); *************** *** 813,817 **** * Method isSeq * - * * @param object * --- 813,816 ---- *************** *** 819,823 **** * */ ! protected boolean isSeq(PyObject object) { if ((object == null) || (object == Py.None)) { --- 818,822 ---- * */ ! public static boolean isSeq(PyObject object) { if ((object == null) || (object == Py.None)) { *************** *** 837,841 **** * Method hasParams * - * * @param params * --- 836,839 ---- *************** *** 843,847 **** * */ ! protected boolean hasParams(PyObject params) { if (Py.None == params) { --- 841,845 ---- * */ ! public static boolean hasParams(PyObject params) { if (Py.None == params) { *************** *** 862,866 **** * Method isSeqSeq * - * * @param object * --- 860,863 ---- *************** *** 868,872 **** * */ ! protected boolean isSeqSeq(PyObject object) { if (isSeq(object) && (object.__len__() > 0)) { --- 865,869 ---- * */ ! public static boolean isSeqSeq(PyObject object) { if (isSeq(object) && (object.__len__() > 0)) { Index: PyConnection.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/PyConnection.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyConnection.java 9 May 2002 01:03:37 -0000 1.10 --- PyConnection.java 10 May 2002 16:11:41 -0000 1.11 *************** *** 118,122 **** * Method classDictInit * - * * @param dict * --- 118,121 ---- Index: Procedure.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/Procedure.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Procedure.java 12 Apr 2002 20:32:45 -0000 1.7 --- Procedure.java 10 May 2002 16:11:41 -0000 1.8 *************** *** 82,87 **** if (name instanceof PyString) { ! this.procedureCatalog = Py.EmptyString; ! this.procedureSchema = Py.EmptyString; this.procedureName = name; } else if (this.cursor.isSeq(name)) { --- 82,87 ---- if (name instanceof PyString) { ! this.procedureCatalog = getDefault(); ! this.procedureSchema = getDefault(); this.procedureName = name; } else if (this.cursor.isSeq(name)) { *************** *** 275,279 **** } ! String name = cursor.datahandler.getProcedureName(procedureCatalog, procedureSchema, procedureName); sql.append("call ").append(name).append("("); --- 275,279 ---- } ! String name = this.getProcedureName(); sql.append("call ").append(name).append("("); *************** *** 324,328 **** /** ! * Method fetchColumns * * @throws SQLException --- 324,328 ---- /** ! * Get the columns for the stored procedure. * * @throws SQLException *************** *** 342,345 **** --- 342,372 ---- pec.close(); } + } + + /** + * The value for a missing schema or catalog. This value is used to find + * the column names for the procedure. Not all DBMS use the same default + * value; for instance Oracle uses an empty string and SQLServer a null. + * This implementation returns the empty string. + * + * @return the default value (the empty string) + * @see java.sql.DatabaseMetaData#getProcedureColumns + */ + protected PyObject getDefault() { + return Py.EmptyString; + } + + /** + * Construct a procedure name for the relevant schema and catalog information. + */ + protected String getProcedureName() { + + StringBuffer proc = new StringBuffer(); + + if (this.procedureCatalog.__nonzero__()) { + proc.append(this.procedureCatalog.toString()).append("."); + } + + return proc.append(this.procedureName.toString()).toString(); } } Index: DataHandler.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/DataHandler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DataHandler.java 11 Jan 2002 21:46:01 -0000 1.6 --- DataHandler.java 10 May 2002 16:11:41 -0000 1.7 *************** *** 54,76 **** } ! /** ! * Method getProcedureName ! * ! * @param PyObject catalog ! * @param PyObject schema ! * @param PyObject name ! * ! * @return String ! * ! */ ! public String getProcedureName(PyObject catalog, PyObject schema, PyObject name) { ! ! StringBuffer procName = new StringBuffer(); ! ! if ((catalog != Py.EmptyString) && (catalog != Py.None)) { ! procName.append(catalog.toString()).append("."); ! } ! ! return procName.append(name.toString()).toString(); } --- 54,59 ---- } ! public Procedure getProcedure(PyCursor cursor, PyObject name) throws SQLException { ! return new Procedure(cursor, name); } |