Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-09

Using parameters with sqldb

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexsander Rosa

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?

Atenciosamente, Alexsander da Rosa Linux User #113925 "Extremismo na defesa da liberdade n?o ? defeito. Modera??o na busca por justi?a n?o ? virtude." -- Barry Goldwater -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090928/aa9b9886/attachment.html>

Reply by email

JoshyFun
to Alexsander Rosa

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.

Best regards, JoshyFun

Reply by email

waldo kitty
to JoshyFun
JoshyFun wrote 13 lines
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.

then why does it exist if not usable?? :? :(

Reply by email

JoshyFun
to waldo kitty

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.

Best regards, JoshyFun

Reply by email

Joost van der Sluis
to JoshyFun
JoshyFun wrote 13 lines
Hello waldo, Tuesday, September 29, 2009, 6:32:22 AM, 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).

.Clear will also do that

Show quoted text 5 lines
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 ?

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.)

Reply by email

JoshyFun
to Joost van der Sluis

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
> 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 ?

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".

Best regards, JoshyFun

Reply by email