Search code examples
t-sqlpostgresqlcompatibilitylazarussqldatatypes

Lazarus Pascal TSQLQuery parameter types for PostgreSQL DB


I've been using ParamByName in Lazarus to specify the parameters to use with different fields. It's mostly been AsString or AsBoolean...

But now I need to use a numeric value that has 8 precisions and 3 decimal digits. This is certainly not currency (IMO).

On the PostgreSQL back-end, I've defined this as Numeric(8,3).

But how do I specify this in Lazarus Pascal?

Is it correct to use AsFloat?

Thanks!


Solution

  • Asfloat is correct I think. Newer FPC versions might also support asBCD or asfmtbcd

    I think it doesn't matter much, because params are passed to postgresql as an array of string. Using BCD might avoid some of float's base2 vs base10 rounding issues, but its support is relatively new.