[DB-SIG] Parameters in DCOracle2

Matthew T. Kromer matt@zope.com
Fri, 16 Aug 2002 10:12:33 -0400


Marcos S=E1nchez Provencio wrote:

>Hello, I am having a problem trying to get some data from an Solaris Ora=
cle
>7.3.3 server. I use the 8.1.7 client in the same machine. The problem is=
 as
>follows:
>
>I get results if I say
>
>    where nombre=3D'SAENS'
>
>but not if I say
>
>    where nombre=3D:p1
>
>and pass a parameter 'SAENS', fetchall returns an empty list
>
>It is funny that I get some results if I say
>
>    where nombre between :p1 and :p1 || 'Z'
>
>or (almost) what I want by saying
>
>    where nombre like :p1 || ' %'
>
>I have been puzzled by Oracle since I am using it (I had used Sybase bef=
ore).
>Is this an Oracle issue or a Python one?
>
>Thank you very much
>
> =20
>

Hello Marcos,

If you use named parameters (ala :p1 etc) you need to pass them in as=20
named parameters to the execute call:

      cursor.execute('select * from table where nombre=3D:p1', p1=3D'SAEN=
S')

Otherwise, you can use positional arguments

     cursor.execute('select * from table where nombre=3D:1', 'SAENS')


--=20
Matt Kromer
Zope Corporation  http://www.zope.com/=20