I'm trying to use parameters with sqldb with no success. At the moment I'm assembling the entire SQL command, but I would like to be able to use the Params property. Is there any online tutorial about this? The SQL.Text property of the SQLQuery object ends with '... LIKE :filtro' and there's a ParamByName['filtro'].Value = 'TESTE%' right before the Open(). What am I doing wrong?
Mailing lists / lazarus / 2009-09
Using parameters with sqldb
6 messages · 4 people · –
- JJoshyFun 3
- AAlexsander Rosa 1
- JJoost van der Sluis 1
- Wwaldo kitty 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hello Lazarus,
Monday, September 28, 2009, 10:20:49 PM, you wrote:
AR> ParamByName['filtro'].Value = 'TESTE%' right before the Open(). What am I AR> doing wrong?
Try using:
.ParamByname('filtro').AsString:='TESTE%';.Value is not a good friend.
JoshyFun wrote 13 lines
then why does it exist if not usable?? :? :(
Hello waldo,
you wrote> .ParamByname('filtro').AsString:='TESTE%'; > > .Value is not a good friend.
wk> then why does it exist if not usable?? :? :(
It is usable, but as it involves variants some conversions could happend in an unexpected way. In fact .value is the only way I know to set the a field to NULL (variant value).
If filtro was a INTEGER field this code:
.ParamByname('filtro').Value:='1234';what should it do ? Raise an error or convert the '1234' to 1234 ? From my point of view it is always better to use the typed forms.
JoshyFun wrote 13 lines
.Clear will also do that
Show quoted text 5 lines
If you really want to use .value, you have to set the right paramkind, so that it knows what type of value it is. (integer, string, bcd etc.)
Hello Joost,
you wrote> It is usable, but as it involves variants some conversions could > happend in an unexpected way. In fact .value is the only way I know to > set the a field to NULL (variant value).
JvdS> .Clear will also do that
Nice to know it.
Show quoted text 5 lines
JvdS> If you really want to use .value, you have to set the right paramkind, JvdS> so that it knows what type of value it is. (integer, string, bcd etc.)
I do not like to use .Value unless it is necessary.
OT: How is the fix process of this issue
http://bugs.freepascal.org/view.php?id=14331 ?
I think it is a major problem and seems that fix is quite "easy".
