[DB-SIG] a little trouble passing values to Oracle using bind variables
Guido van Rossum
gvanrossum at gmail.com
Tue May 17 16:21:17 CEST 2005
Are you *sure* the 3rd variant doesn't work? I'd expect that to work.
'\r' should work just as well.
Which Oracle interface are you using?
On 5/17/05, Michael.Coll-Barth at verizonwireless.com
<Michael.Coll-Barth at verizonwireless.com> wrote:
> All,
>
> As the subject line says, I am having some trouble passing bind variables to
> Oracle. When I pass a printable string value, such as 'NM', I get data.
> When I try to pass a non-printable character, such as 'return' - chr(13), I
> get no data back. I can't simply make NactionCode = chr(13), as python
> would change the value of NactionCode to '\r' and Oracle sees this as a two
> byte character, and not chr(13). I have looked into how Oracle might accept
> something like '\x00' for chr(0), but to no avail.
>
> Any thoughts?
>
> thanks,
> Michael
>
> def goGetIt( NactivityDt, NactionCode ):
>
> dataQuery = '''select a, b, c
> from %s
> where activityDt = :NactivityDt
> and actionCode = :NactionCode
> order by %s
> ''' % ( schema.tableName )
>
> dbm.cursor.execute(dataQuery, NactivityDt = activityDt, NactionCode =
> actionCode )
> result = dbm.cursor.fetchall()
>
> return result
>
> NactivityDt = '12-apr-2005'
> NactionCode = 'NM'
> act1 = goGetIt( NactivityDt, NactionCode )
>
> NactivityDt = '12-apr-2005'
> NactionCode = 'chr(13)'
> act2 = goGetIt( NactivityDt, NactionCode )
>
> NactivityDt = '12-apr-2005'
> NactionCode = chr(13)
> act3 = goGetIt( NactivityDt, NactionCode )
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the DB-SIG
mailing list