[SOLVED]: [Zope-DB] ZSQL meyhod fr an Oracle Stored Procedure that
Returns a ref_cur
m.banaouas
banaouas.medialog at wanadoo.fr
Mon Nov 19 02:33:23 EST 2007
solution from zope-db archives was pointed to me by Maciej Wisniowski :
http://www.nabble.com/Re:-RE-:-How-lunch-SQL-request-from-python-script---t3039608.html
and here is the final implementation:
1-add a Z cxOracle Database Connection (myconnection) via pmi
2-add a python script for external method in Plone\Data\Extensions :
# myscript.py
def mymethod(self , somename):
conn = self.myconnection()
curext = conn.db.cursor()
curint = conn.db.cursor()
sql = "begin MY_PACKAGE.MY_PROC(:p_Cursor, :p_NAME); end;"
curext.execute(sql, (curint, somename))
data = TransformCursorIntoReadableText(curint)
return data
3-add an external method :
Id=mymethod
Module name=myscript
Function Name=mymethod
This external method can be called from a "Script (python)".
banaouas a écrit :
> Hi,
> I'm starting to query an oracle 10g XE database from zope using ZSQL.
> I installed cx_Oracle-4.3.3-10g.win32-py2.4.exe and
ZcxOracleDA-0.5.tar.gz.
> It works fine for simple queries.
> But how can I query a stored procedure returning a cursor ?
> In python script, this sample works fine:
> con = cx_Oracle.connect("my_user", "my_pass", "my_server")
> cur = con.cursor()
> sql = "begin MY_PACKAGE.MY_PROC(:p_Cursor, :p_NAME); end;"
> cursor.execute(sql, (cur, 'DUPONT%'))
> ...
> con.commit()
>
> thanks
>
More information about the Zope-DB
mailing list