From: brian z. <bz...@us...> - 2001-12-29 18:00:18
|
Update of /cvsroot/jython/jython/Doc In directory usw-pr-cvs1:/tmp/cvs-serv25219/Doc Modified Files: zxjdbc.ht Log Message: changed rowid to lastrowid per the spec Index: zxjdbc.ht =================================================================== RCS file: /cvsroot/jython/jython/Doc/zxjdbc.ht,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -d -r2.3 -r2.4 *** zxjdbc.ht 2001/12/21 04:10:00 2.3 --- zxjdbc.ht 2001/12/29 18:00:15 2.4 *************** *** 137,140 **** --- 137,196 ---- </pre> + <p> + To call a stored procedure or function provide the name and any params to <code>callproc</code>. + The database engine must support stored procedures. The examples below have been tested with + Oracle, SQLServer and Informix. Refer to the Python DP API spec for how OUT and INOUT parameters + work. + </p> + <p> + NOTE: The name of the stored procedure can either be a string or tuple. This is NOT portable to + other DB API implementations. + <pre> + <b><i>SQL Server</b></i> + >>> c = db.cursor() # open the database as in the examples above + >>> c.execute("use northwind") + >>> c.callproc(("northwind", "dbo", "SalesByCategory"), ["Seafood", "1998"], maxrows=2) + >>> for a in c.description: + ... print a + ... + ('ProductName', -9, 40, None, None, None, 0) + ('TotalPurchase', 3, 17, None, 38, 2, 1) + >>> for a in c.fetchall(): + ... print a + ... + ('Boston Crab Meat', 5318.0) + ('Carnarvon Tigers', 8497.0) + >>> c.nextset() + 1 + >>> print c.fetchall() + [(0,)] + >>> print c.description + [('@RETURN_VALUE', 4, -1, 4, 10, 0, 0)] + >>> + </pre> + + <pre> + <b><i>Oracle</b></i> + >>> c = db.cursor() # open the database as in the examples above + >>> c.execute("create or replace function funcout (y out varchar2) return varchar2 is begin y := 'tested'; return 'returned'; end;") + >>> params = [None] + >>> c.callproc("funcout", params) + >>> print params + ['tested'] + >>> print c.description + [(None, 12.0, -1, None, None, None, 1)] + >>> print c.fetchall() + [('returned',)] + >>> + </pre> + + <p>When finished, close the connections.</p> + + <pre> + >>> c.close() + >>> db.close() + >>> + </pre> + <h3>Standard extensions to the Python DB API</h3> *************** *** 159,163 **** Statement.getUpdateCount</a></dd> ! <dt><p><code class="methodname">cursor.rowid</code></p></dt> <dd>The value obtained from calling <a --- 215,219 ---- Statement.getUpdateCount</a></dd> ! <dt><p><code class="methodname">cursor.lastrowid</code></p></dt> <dd>The value obtained from calling <a *************** *** 273,280 **** stored procedure or function. Given the JDBC type, return the appropriate PyObject subclass from the Java object at column col in the CallableStatement.</dd> ! <dt><p><code class="methodname">public void registerOut(CallableStatement statement, ! int index, int colType, int dataType) throws SQLException;</code></p></dt> ! <dd>This method is called when a stored procedure or function is executed and OUT parameters ! need to be registered with the statement.</dd> </dl> --- 329,339 ---- stored procedure or function. Given the JDBC type, return the appropriate PyObject subclass from the Java object at column col in the CallableStatement.</dd> ! <dt><p><code class="methodname">public void registerOut(CallableStatement statement, int ! index, int colType, int dataType, String dataTypeName) throws SQLException;</code></p></dt> ! <dd>This method is called to register an OUT or INOUT parameter on the stored procedure. ! The dataType comes from java.sql.Types while the dataTypeName is a vendor specific string.</dd> ! <dt><p><code class="methodname">public String getProcedureName(PyObject catalog, PyObject ! schema, PyObject name);</code></p></dt> ! <dd>This method is called to build a stored procedure's name.</dd> </dl> *************** *** 354,361 **** <pre> [default] ! name=mysql_ziclix [jdbc] ! name=mysql_ziclix url=jdbc:mysql://localhost/ziclix user= --- 413,420 ---- <pre> [default] ! name=mysql [jdbc] ! name=mysql url=jdbc:mysql://localhost/ziclix user= *************** *** 365,369 **** [jdbc] ! name=ora_ziclix url=jdbc:oracle:thin:@localhost:1521:ziclix user=ziclix --- 424,428 ---- [jdbc] ! name=ora url=jdbc:oracle:thin:@localhost:1521:ziclix user=ziclix |