SQL Variable Substitution Question

Tim Roberts timr at probo.com
Thu Jun 8 00:35:16 EDT 2000


liang at cad.gatech.edu (Shengquan Liang) wrote:
>
>say i have yyyy = 1000
>
>in the documentation of DC Oracle, it says that
>i shoul d use 'select * from attt'
>		'where bbbb = :yyyy'
>
>to make it work.

No, SQL doesn't have any idea what your Python variables are.  To use the
":" feature, you have to have set an _SQL_ variable called "yyyy".  How you
do that varies with the backend.

In your case, it's probably easier to build the complete string in Python
and pass that to the database:

  'select * from attt where bbbb = %d' % yyyy

>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 haven't bound the SQL variable yyyy to any value.  As I said, the
method for doing that varies with the backend.

--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list