this bug is fixed in SQLA 0.6, in that the oracle dialect knows how to  
"quote" bind parameters that contain illegal characters.   its a non- 
trivial change since cx_oracle requires that the bind parameter  
dictionary itself also contain the quote characters.

For 0.5, there's a few options.

Either use an explicit bind param:

select(table.c.col == bindparam('somekey', value='5412345'))

or this is a monkeypatch that will use the "key" as the source of the  
bind name:

from sqlalchemy.sql.expression import _BindParamClause, ColumnClause

def _bind_param(self, obj):
     return _BindParamClause(self.key, obj, type_=self.type,  
unique=True)



On Feb 2, 2009, at 11:48 AM, phcornelus wrote:

>
> Hello,
>
> I work with sqlalchemy 0.5.2, python 2.5 and Oracle 8.17.
>
> Consider the following code:
>
> ora = create_engine('oracle://user:passw...@server/INSTANCE',
>                    use_ansi=False,
>                    label_length=None)
> metadata = MetaData(bind=ora)
> part_list_table = Table('part_list', metadata,
>        Column('$COID', COIDtype(8), key='coid', primary_key=True),
>        include_columns=['$COID',
>                         's_part_number'],
>        autoload=True,
>        schema = 'DMAGS1'
>        )
>
> sel = part_list_table.select( part_list_table.c.coid ==
> '543392B3A4626F76' ).execute()
> cursor = iter(sel)
> part = cursor.next()
>
> The last instruction raises an exception:
>
> ...DatabaseError: (DatabaseError) ORA-01036: illegal variable name/
> number
> 'SELECT "DMAGS1".part_list.s_part_number, "DMAGS1".part_list."$COID"
> \nFROM "DMAGS1".part_list \nWHERE "DMAGS1".part_list."$COID" = :
> $COID_1' {'$COID_1': 'T3\x92\xb3\xa4bov'}
>
> This is due to the bind parameter name “$COID_1”. The ‘$’ character is
> not allowed in this context. I get the same error from sqlplus, and
> the python script works fine when I select on the column
> ‘s_part_number’.
>
> I tried to use ‘label_length=5’ in create_engine, but it generates the
> bind parameter name ‘_1’, which is rejected by oracle for the same
> reason.
>
> Does anyone know a workaround? Changing the column name is not a
> option.
>
> Thanks,
>
> Philippe
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to