[sqlalchemy] Re: Result Set From An Oracle Function
On May 9, 2008, at 4:26 AM, Dan wrote: Using cx_Oracle, the following does the trick (note this is a contrived example): def test(orcl_conn): curs = orcl_conn.cursor() cursorToBind = orcl_conn.cursor() curs.execute(begin :cr1 := aaa_test(pWhen = :arg1); end;, arg1 = None, cr1 = cursorToBind) marketData = {}# dictionary to hold the records i = 1 for col in cursorToBind.fetchall(): marketData[str(i)] = col i = i + 1 return marketData why is it necessary to send the cursor in as a bind parameter ? I've used custom PL/SQL plenty and i've never heard of that technique. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Result Set From An Oracle Function
Not sure how to do it otherwise. This is how its been coded -- what is the alternative? On May 9, 8:34 am, Michael Bayer [EMAIL PROTECTED] wrote: On May 9, 2008, at 4:26 AM, Dan wrote: Using cx_Oracle, the following does the trick (note this is a contrived example): def test(orcl_conn): curs = orcl_conn.cursor() cursorToBind = orcl_conn.cursor() curs.execute(begin :cr1 := aaa_test(pWhen = :arg1); end;, arg1 = None, cr1 = cursorToBind) marketData = {}# dictionary to hold the records i = 1 for col in cursorToBind.fetchall(): marketData[str(i)] = col i = i + 1 return marketData why is it necessary to send the cursor in as a bind parameter ? I've used custom PL/SQL plenty and i've never heard of that technique. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Result Set From An Oracle Function
On May 9, 2008, at 10:20 AM, Dan wrote: Not sure how to do it otherwise. This is how its been coded -- what is the alternative? what happens if you just say, cursor.execute(select * from aaa_test(pWhen=:arg1, {'arg1':None}) using raw cx_oracle (and then cursor.fetchall()) ? doesn't work ? it almost looks like you're using an OUT param, which we *do* support, that looks like this: result = engine.execute(text(begin foo(:x, :y, :z); end;, bindparams=[bindparam('x', Numeric), outparam('y', Numeric), outparam('z', Numeric)]), x=5) print result.out_parameters otherwise we'd have to build another construct like x = bound_cursor() to support this inline with SQLA. you do of course have the option to just keep it as a cx_oracle thing - just grab a cursor off of a Connection: conn = engine.connect() cursor = conn.connection.cursor() then do the cx_oracle specific work with cursor. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---