Tuesday, November 12, 2013

Calling an Oracle Stored Procedure in Java or in Python

I needed to schedule the execution of a Stored Procedure from a cron job.... somebody advised me to use a Java class to do that.
It proved to be really cumbersome... I have followed this example and it's working, but it's very verbose and ugly.
Also, in Java there is no built-in support for getopt style of reading CLI parameters, and using the gnu getopt library seemed overkill to me.
So at the end I will keep using good old zxJDBC from a Python (WLST) script, which supports stored procedures in a VERY simple way: http://www.jython.org/archive/21/docs/zxjdbc.html
db = zxJDBC.connect(...)
c = db.cursor()
params = [None]
c.callproc("funcout", params)

The only disturbing thing is that the startup time for WLST is a bit long, much longer than for a JVM.... but who cares, really, for a job who has to be called once every 10 minutes...


No comments: