[Lazarus] Using parameters with sqldb

Joost van der Sluis joost at cnoc.nl
Tue Sep 29 14:47:25 CEST 2009


On Tue, 2009-09-29 at 13:17 +0200, JoshyFun wrote:
> 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

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






More information about the Lazarus mailing list