[Zope] REF CURSOR variables and Zope Stored Prodcedures in Oracle

Ricardo Seghizzi ricardo@cnbe.mar.org.uk
Fri, 10 Aug 2001 10:15:15 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_00FA_01C12185.5944E9A0
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Can someone help me?

I have a package with a procedure  like that:

PACKAGE test_pkg IS

  TYPE rc_assuntos IS REF CURSOR
=20
   PROCEDURE GETALL(result IN OUT rc_assuntos);
  =20
 END;

PACKAGE BODY TEST_PKG IS
 =20
  PROCEDURE GETALL(result IN OUT rc_assuntos) IS
  BEGIN
   OPEN result FOR SELECT tema_primario  FROM ASSUNTOS;
  END
=20
END;

As you can see this procedure has as input/output variable type a  REF =
CURSOR.

I have created a ZSP to use the function above:

ZSP description:=20
procedure TEST_PKG.GETALL has arguments:
	RESULT IN OUT REF CURSOR


I cold not test it because it asked for a cursor as input.
=20
So... I tried to use an Python Script like that to pass and receive a =
cursor for this ZSP:

"""
teste
NO PARAMETERS LIST.
"""

db=3D context.Oracle_database_connection   #    use my current Oracle =
conection.  Is it correct?
c=3D db.cursor()                                           #    create a =
cursor object =20
dbsproc =3D context.ZOSP2(c)                      #    call mu ZSP and =
pass  the cursor object
rs=3Dc.fetchall()                                           #    get the =
result set and use it
print rs



When I run this  Script I have the folloing error:

Error Type: AttributeError
Error Value: cursor

So what is wrong? =20
=20
What can I do to receive a REF CURSOR type from a ZSP from ZOPE?=20
=20
Or getting a REF CURSOR type from an Oracle procedure using ZOPE?
=20
Is there an easier way?

Can I use External Method? If I can, how do I do it?

Many thanks.=20
=20

Ricardo

------=_NextPart_000_00FA_01C12185.5944E9A0
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Can someone help me?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have a package with =
a&nbsp;procedure&nbsp; like=20
that:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>PACKAGE test_pkg IS</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp; TYPE rc_assuntos IS REF=20
CURSOR</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; PROCEDURE GETALL(result IN =
OUT=20
rc_assuntos);<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;END;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>PACKAGE BODY TEST_PKG IS<BR>&nbsp; =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; PROCEDURE GETALL(result IN OUT =
rc_assuntos)=20
IS<BR>&nbsp; BEGIN<BR>&nbsp; &nbsp;OPEN result FOR SELECT =
tema_primario&nbsp;=20
FROM ASSUNTOS;<BR>&nbsp; END</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>END;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>As you can see this procedure&nbsp;has =
as=20
input/output variable type a&nbsp;&nbsp;REF CURSOR.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have created a ZSP to use the =
function=20
above:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>ZSP description: </FONT></DIV>
<DIV><FONT size=3D4><PRE>procedure TEST_PKG.GETALL has arguments:
	RESULT IN OUT REF CURSOR</PRE><PRE>
</PRE></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I cold not test it because it asked for =
a cursor as=20
input.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So... I tried to use an Python Script =
like that to=20
pass and receive a cursor for this ZSP:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"""<BR>teste</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>NO PARAMETERS LIST.</FONT><FONT =
face=3DArial=20
size=3D2><BR>"""</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>db=3D=20
context.Oracle_database_connection&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; use =
my=20
current Oracle conection.&nbsp; Is it correct?<BR>c=3D=20
db.cursor()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbs=
p;create=20
a cursor object&nbsp; <BR>dbsproc =3D=20
context.ZOSP2(c)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
#&nbsp;&nbsp;&nbsp;&nbsp;call mu ZSP and pass&nbsp; the cursor=20
object<BR>rs=3Dc.fetchall()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
#&nbsp;&nbsp;&nbsp; get the result set and use it<BR>print =
rs</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>When I run this&nbsp; Script I have the =
folloing=20
error:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Error Type:=20
AttributeError</STRONG><BR><STRONG>Error Value: =
cursor</STRONG><BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>So what is =
wrong?&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>What can I do to receive a REF CURSOR =
type from a=20
ZSP from ZOPE?&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Or getting a REF CURSOR type from an =
Oracle=20
procedure using ZOPE?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Is there an easier way?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Can I use External Method? If I can,=20
how&nbsp;</FONT><FONT face=3DArial size=3D2>do&nbsp;I&nbsp;do =
it?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Many thanks. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Ricardo</DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_00FA_01C12185.5944E9A0--