Oracle Function Out Params

321 views
Skip to first unread message

Justin Valentini

unread,
May 31, 2012, 12:17:48 PM5/31/12
to sqlal...@googlegroups.com
I'm having difficulty determining how to correctly call an oracle package function which returns a numeric value. I want to call this:

BEGIN :out := my_schema.my_package.test_function(); END;

I tried calling that using sqlalchemy.text() but I don't understand how to tell the procedure I want to use an out parameter. I also tried using the func module but couldn't get that to work either. Can someone point me to an example of the correct syntax?

Michael Bayer

unread,
May 31, 2012, 3:31:13 PM5/31/12
to sqlal...@googlegroups.com
There's an outparam() construct specifically for Oracle OUT parameters.

Here's an example:

        from sqlalchemy import text, bindparam, outparam

        result = \
            db.execute(text('begin foo(:x_in, :x_out, :y_out, '
                               ':z_out); end;',
                               bindparams=[bindparam('x_in', Float),
                               outparam('x_out', Integer),
                               outparam('y_out', Float),
                               outparam('z_out', String)]), x_in=5)
        print result.out_parameters

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/-TPZ33REargJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Justin Valentini

unread,
Jun 1, 2012, 10:51:40 AM6/1/12
to sqlal...@googlegroups.com
Thanks Michael!
To unsubscribe from this group, send email to sqlalchemy+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages