[python-sybase] Can't put LIKE parameter in parameter dict?
Marcos Sánchez Provencio
marcos at burke.ath.cx
Fri, 11 Jun 2004 21:29:00 +0200
It might be that the db server/api takes incorrect decisions about the
type of the parameter...
You may try casting the parameter:
and symbol like cast(@s as varchar(100))
By the way, you might use sigle quotes around string constants, it is
more portable (triple quotes around sql looks better too ;-)
El jue, 10-06-2004 a las 15:18, Skip Montanaro escribió:
> Can someone explain why these two seemingly identical queries return
> different results? Can't LIKE wildcards be given in parameter dictionari=
es?
>
> >>> c.execute('select distinct symbol, open_time, close_time,'
> ... ' session_start, session_end, instrument=
'
> ... ' from underlying_sessions'
> ... ' where instrument = @i'
> ... ' and symbol like "M%"',
> ... {"@i": "E"})
> >>> len(c.fetchall())
> 402
> >>> c.execute('select distinct symbol, open_time, close_time,'
> ... ' session_start, session_end, instrument=
'
> ... ' from underlying_sessions'
> ... ' where instrument = @i'
> ... ' and symbol like @s',
> ... {"@i": "E",
> ... "@s": "M%"})
> >>> len(c.fetchall())
> 0
>
> Thanks,