[Zope-DB] Oracle Date in DCOracle2's Stored Procedure

Bo M. Maryniuck b.maryniuk@forbis.lt
Mon, 20 Jan 2003 11:20:12 +0200


On Friday 17 January 2003 17:02, Matthew T. Kromer wrote:
> For using from stored procedures, you should  pass dates in that you
> create with the Date, Time or DateTime constructors on the DCOracle2
> module, e.g.
>
> date =3D DCOracle2.Date(2003,01,11)
>
> c.procedure.pm.pm_08.insert_day_report(date, ...)

Well. If I do in right that way as you described it works for sure. But o=
nly if I=20
invoke it from the pure Python in my command line using Zope's=20
Python or other one, installed in my system. It works without problems.=20

But I'm asking about why this code below (simple stupid External Method, =
with id "sp" in a traceback below)=20
does not work -- see comments in a code (error cut&pasted below). Seems t=
hat SP.py=20
is not broken, since I event can't bound OracleDate type directly as in y=
our example above into
a procedure (a realy trouble probably deeper -- in DCOracle2.py or even i=
n dco2.so):

def insertDayReport(self, parent, odc):
    """ blah... """
    import DCOracle2 as dc

    # This get current Z Oracle DB Connection for current user   =20
    db =3D getattr(parent, odc)._v_database_connection.db
    cr =3D db.cursor()

    # If I call cr.procedure.pm.pm_08.insert_day_report.__doc__ -- it ret=
urns me
    # a corrent procedure description

    a =3D cr.procedure.pm.pm_08.insert_day_report(P_DT =3D dc.Date(2003, =
2, 10), # <-- CRASH HERE
                                                P_ACL_ID =3D 844L,
                                                P_DESCRIPTION =3D 'Descr'=
,
                                                P_SPENT_DAYS  =3D 1,
                                                P_DONE_PRC    =3D 10,
                                                P_COMMENT     =3D 'Commen=
t',
                                                P_ERR_MSG     =3D '')
    # Stupid output
    return '<pre>%s</pre>' % a


Returns me error:

=09Error Type: ValueError
=09Error Value: invalid data type bound

Traceback (innermost last):
  File /opt/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_m=
odule
  File /opt/zope/lib/python/ZPublisher/Publish.py, line 114, in publish
  File /opt/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exc=
eption_hook
    (Object: workload)
  File /opt/zope/lib/python/ZPublisher/Publish.py, line 98, in publish
  File /opt/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply
    (Object: testSp)
  File /opt/zope/lib/python/ZPublisher/Publish.py, line 39, in call_objec=
t
    (Object: testSp)
  File /opt/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 252, in _=
_call__
    (Object: testSp)
  File /opt/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 283, in _=
bindAndExec
    (Object: testSp)
  File /opt/zope/lib/python/Products/PythonScripts/PythonScript.py, line =
302, in _exec
    (Object: testSp)
    (Info: ({'script': <PythonScript instance at 9525540>, 'context': <Fo=
lder instance at 9165c08>, 'container': <Folder instance at 9165c08>, 'tr=
averse_subpath': []}, (), {}, None))
  File Script (Python), line 6, in testSp
  File /opt/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, li=
ne 205, in __call__
    (Object: sp)
    (Info: ((<Folder instance at 9676aa0>, 'bo~pman~10430499921111152228'=
), {}, None))
  File /opt/zope/Extensions/SP_insert_day_report.py, line 16, in insertDa=
yReport
    (Object: workload)
  File /opt/zope/lib/python/Products/ZOracleDA/DCOracle2/DCOracle2.py, li=
ne 1492, in __call__
    (Object: PM.PM_08.INSERT_DAY_REPORT)
  File /opt/zope/lib/python/Products/ZOracleDA/DCOracle2/DCOracle2.py, li=
ne 959, in execute
ValueError: (see above)

To repeat again how look my Oracle Stored procedure:

function PM.PM_08.INSERT_DAY_REPORT returns OUT NUMBER, has arguments:
        P_DT IN DATE
        P_ACL_ID IN NUMBER
        P_DESCRIPTION IN VARCHAR2
        P_SPENT_DAYS IN NUMBER
        P_DONE_PRC IN NUMBER
        P_COMMENT IN VARCHAR2
        P_ERR_MSG IN OUT VARCHAR2

--=20
Regards, Bogdan

Most security experts REALLY believe in firewalls. The expect that, when =
they
die, arrive at the great firewall in the sky where Saint Peter is running=
 a
default policy of REJECT.
=09=09--- Sander Plomp