Page 1 of 1

Select field with calculation

Posted: 17.10.2014, 16:35
by royyu
I am using ZeosLib 7.1 + Delphi 2009. And have a sql statement like below:
select round(amount / exchange_rate,2) as fieldA from tableA;
but the return type of fieldA just like String, I have set the sub-total of that field on a grid, but the sub-total is empty. I have try to cast it as numeric, but still not work.

Re: Select field with calculation

Posted: 17.10.2014, 21:52
by EgonHugeist
This is because SQLite does not retrieve a type info for the result of a function and we are not able to load any informations by using metadata-informations.

If you want to track root of eval: Just debug TZSQLiteResultSet.Open; in ZDbcSqliteResultset.pas...


Edit: Did read some more SQLite-docs.. found something interesting: http://www.sqlite.org/c3ref/table_column_metadata.html

I'll check if this works an can be used -> it's a Preprocessor define..

Re: Select field with calculation

Posted: 18.10.2014, 17:40
by royyu
Thanks for your reply!

But I have face another problem now.
I need to input some Traditional Chinese into the sqlite DB. For example '當歸', but it become 'vuxk' after saved. So I try to use a TZUpdateSQL object and write my own update sql.

I found that if I write the update sql using param like:
Update tableA set fieldA = :fieldA;
then it become 'vuxk'.

If I write the value directly like:
Update tableA set fieldA = '當歸';
then it works. But I need to update multi-records in one time, so I can't write the value directly like that.

My TZConnection setting is:
ClientCodepage: UTF-8
ControlsCodePage: cCP UTF16
AutoEncodeStrings: True

and I am using Win7 Traditional Chinese.

Thanks!