Hey all,

I have to call some pre-existing Oracle stored procedures that have
cursor out parameters.  I've had no luck doing this short of using
"raw" cursors.  Is there a better way to do this?

Here is a simple stored procedure modelled after what I have to call:

create or replace package TEST_PKG as
    type refcur is ref cursor;
    procedure simple_read(p_param out refcur);
end TEST_PKG;
/

create or replace package body TEST_PKG as
    procedure simple_read(p_param out refcur) as
    begin
        open p_param for
            select name from some_table;
    end simple_read;
end TEST_PKG;
/


Here is the only code I was able to find that worked:

import sqlalchemy

engine = sqlalchemy.create_engine('oracle://<user>:<pwd>@<db>')
oracle_conn = engine.raw_connection()

in_cursor = oracle_conn.connection.cursor()
out_cursor = oracle_conn.connection.cursor()
in_cursor.execute('begin TEST_PKG.simple_read(:x); end;', x =
out_cursor)

results = out_cursor.fetchall()
print repr(results)


Any suggestions in how I can better do this with sqlalchemy?

Thanks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to