[DB-SIG] Re: python module as external library for Oracle?

Andy Todd andy47@halfcooked.com
Wed, 12 Feb 2003 13:47:29 +0000


On Tue, Feb 11, 2003 at 02:35:54PM -0800, Mike Rovner wrote:
> "Simon Saubern" <simon.saubern@molsci.csiro.au> wrote in message
> news:p05100306ba6e34332d8d@
> >
> > I'd like to set-up a trigger within Oracle that would call an
> > external library to do some calculations on new rows inserted into
> > Oracle tables.
> >
> > Can this external library be a python script, or do I have to compile
> > the python code into C? If so, how do I go about doing that?
> 
> AFAIK since Oracle8 on Windows platform there is a possibility to call
> arbitrary OCX from within PLSQL code.
> You can utilize that for python binding.
> 
> On the other hand that solution is not portable and as Oracle itself
> mentioned not so stable to recommend it. ;)
> 
> Or you can use jython.
> 
> Best wishes,
> Mike
> 
> PS. I wish I could use python instead of java for oracle scripting.
> 
> 
> 

According to Chapter 10 of the Oracle Application Developer's Guide;

"""
Oracle lets you work in different languages:
 - PL/SQL 
 - C, by means of the Oracle Call Interface (OCI)
 - C or C++, by means of the Pro*C/C++ precompiler
 - COBOL, by means of the Pro*COBOL precompiler
 - Visual Basic, by means of Oracle Objects for OLE (OO4O)
 - Java, by means of the JDBC Application Programmers Interface (API)
"""
If you have a technet account you can view it at;

http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg11rtn.htm

So the answer to your question is no. If you want to do it synchronously. 

If you don't absolutely definitely need the trigger and just want to periodically process the data then I'd suggest a Python script triggered by cron (or other system specific scheduler, e.g. AT on Windows). Otherwise you are stuck I'm afraid.

Its a useful rule of thumb that Oracle works well within Oracle but doesn't interact well with the outside world. Mainly because it *is* a multi platform database.

Regards,
Andy
-- 
--------------------------------------------------------------------------------
>From the desk of Andrew J Todd esq - http://www.halfcooked.com/