You are right, this is oversimplified example. It doesn't require output parameter, I was just thinking generally. However, it is exactly the kind of example I require at the moment.

On 3/16/06, Michael Bayer <[EMAIL PROTECTED]> wrote:

does this example even require the "result" output parameter ?  why
cant you do a SELECT from cc_util.func ?

you can almost use the "func" keyword for this but it currently does
not supported dotted names like that, also does it need a "named"
argument like that ?  so for that function as is, the most succinct is:

        result = engine.text("select cc_util.func(i_name=>:name) from
dual").scalar(name=name)

if you really wanted OUT params that would be a new feature, either
an OutputBindParameter or a flag on BindParameter for that, then
supporting engines would have to check for those and call the
appropriate method off the DBAPI.  this wouldnt be a huge change.

also, a cursor is most easily accessible via:

        cursor = engine.connection().cursor()

and if you want to use it in an execute:

        engine.execute(sql, params, cursor=cursor)

or an execute of a compiled:

        engine.execute_compiled (mytable.select().compile(), params,
cursor=cursor)

engine docstring at:

        http://www.sqlalchemy.org/docs/
docstrings.myt#docstrings_sqlalchemy.engine_SQLEngine

On Mar 16, 2006, at 2:38 PM, Qvx 3000 wrote:

> This is what I'm currently doing:
>
>     sql = '''BEGIN :result := cc_util.func(i_name => :name); END;'''
>     oramod = __engine__.engine.module
>     oracur = __engine__.engine.connection().connection.cursor()
>     result_var = oracur.var(oramod.NUMBER)
>     oracur.execute(sql, dict(name = name, result = result_var))
>     return result.getvalue ()
>
> Is there a better way? Maybe even a way to call a stored procedure
> automatically.
>
> Tvrtko


Reply via email to