Python and PL/SQL

I

infidel

vb_bv said:
Does Pyton PL/SQL programming language of Oracle support?

Thx

PL/SQL is only supported *inside* Oracle databases. Python can be used
to call PL/SQL procedures (I recommend the cx_Oracle module), but you
can't run Python inside the database like PL/SQL.
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

vb_bv said:
Does Pyton PL/SQL programming language of Oracle support?

Python supports calling Oracle PL/SQL procedures. Here's an example
using the cx_Oracle database adapter:
.... BEGIN
.... PKG_Test.Test;
.... END;
.... """)

cx_Oracle also works with all types I needed, including passing ARRAYs
to stored procedures, and getting REFCURSORs back.

-- Gerhard
 
J

Jorge Godoy

Gerhard Häring said:
In my not so humble opinion, instead of all this fancy stuff, you will be
better off writing your stored procedures in PL/SQL, which is a very good
language for manipulating data, and writing portable, efficient and
maintainable server-side database code.

And if Python is the requirement, but not Oracle, one can write "stored
procedures" (functions is the name) in Python with PostgreSQL. ;-)
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

infidel said:
PL/SQL is only supported *inside* Oracle databases. Python can be used
to call PL/SQL procedures (I recommend the cx_Oracle module), but you
can't run Python inside the database like PL/SQL.

If one is really really really insisting on running Python code inside
an Oracle database, I think it could be done: you can write Oracle
stored procedures in C libraries, Java libraries and even .NET libraries
(10g on win32). And there are Python implementations for C, Java and .NET.

So much for the theory.

In my not so humble opinion, instead of all this fancy stuff, you will
be better off writing your stored procedures in PL/SQL, which is a very
good language for manipulating data, and writing portable, efficient and
maintainable server-side database code.

-- Gerhard
 
V

vb_bv

Thanks for your answers.
I would like to document with Python PL/SQL of programs, so similarly
as javadoc for Java.
I do not know whether it is possible. If yes, I would like to know how.

Thx
 
D

Diez B. Roggisch

vb_bv said:
Thanks for your answers.
I would like to document with Python PL/SQL of programs, so similarly
as javadoc for Java.
I do not know whether it is possible. If yes, I would like to know how.


Is it possible - yes. Has it been done? I doubt it. You can fetch the
sourcecode of oracle packages through sql-statements (google for how to
do it), and then process it with whatever tool you like. But you will
have to write your own parser and generator for that, pydoc or epydoc
won't be of much use here. However, implementing such a thingy in
python is certainly a good idea.

Diez
 
I

infidel

Thanks for your answers.
I would like to document with Python PL/SQL of programs, so similarly
as javadoc for Java.
I do not know whether it is possible. If yes, I would like to know how.

All of the source code for procedures and packages in an oracle
database can be retreived from the USER_SOURCE view. It's just plain
text, though, and one record per line. Parsing it for documentation
would be up to you.

There are other views that might be useful too, like USER_TABLES,
USER_TAB_COLUMNS, USER_OBJECTS, USER_PROCEDURES, USER_ARGUMENTS, etc
etc etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,270
Messages
2,571,348
Members
48,034
Latest member
JaimieBarn

Latest Threads

Top