Query parameters

For safer and faster database process, the WHERE clause of the request expects some parameters to be specified. They are bound in the ? appearance order in the WHERE clause of the [CreateAnd]FillPrepare query method.

Standard simple kind of parameters (RawUTF8, integer, double..) can be bound directly - as in the sample code above for Name or Sex properties. The first parameter will be bound as 'A%' RawUTF8 TEXT, and the second as the 1 INTEGER value.

Any TDateTime bound parameter shall better be specified using DateToSQL() or DateTimeToSQL() functions, as such:

 aRec.CreateAndFillPrepare(Client,'Datum=?',[DateToSQL(EncodeDate(2012,5,4))]);
 aRec.CreateAndFillPrepare(Client,'Datum<=?',[DateTimeToSQL(Now)]);

For TTimeLog / TModTime / TCreateTime kind of properties, please use the underlying Int64 value as bound parameter.

Any sftBlob property should better be handled separately, via dedicated RetrieveBlob and UpdateBlob method calls, if the data is expected to be big (more than a few MB). But you can specify a small BLOB content using an explicit conversion to the corresponding TEXT format, by calling BinToBase64WithMagic() overloaded functions when preparing such a query.

Feedback is welcome in our forum.