SQL Variable Substitution Question

Bjorn Pettersen bjorn at roguewave.com
Wed Jun 7 16:45:02 EDT 2000


Shengquan Liang wrote:
> 
> 'm trying to make a query using varible in a
> Python program.
> 
> say i have yyyy = 1000
> and i want to
> 
>  select * from attt
>  where bbbb = yyyy
> 
> in the documentation of DC Oracle, it says that
> i shoul d use 'select * from attt'
>                 'where bbbb = :yyyy'
> 
> to make it work.
> 
> BUT, when i tried it this way, the
> iDC oracle reponded by:
> 
>   oci.err:(1008,'ORA-1008: not all variables bound\012')
> 
> what's the problem with that?

You need to pass the yyyy varible, so it can be bound by the database
module.  I don't have it handy so I forget the syntax, but it should
look something like:

  cn.execute( 'select * from attt where bbb = :yyyy', (yyyy,) )

hth,
--bjorn




More information about the Python-list mailing list