asString x asInteger, when value is zero. lazarus / 16-Databases ---------------------------------------------------------------------- zuibaf · 2017-12-18 19:46 In the database Postgresql, I defined the field as: ball numeric not null, When one register, have value '0' (zero), the property asString return a empty string, instead of returning a string with value '0'. In the component TSqlQuery, when try access the valor as String, so: var    ball: string; begin sqlRegister := TSqlQuery.Create; ... ball := sqlRegister.FieldByName('ball').asString, asString, returned a empty string instead of a string with value zero. I know I should use AsInteger because the value of the field in the table is numeric, however, I am populating the data in a STRINGGRID. However, I found that the behavior of asString was to convert the value zero to a string with the value zero, however, it converts with an empty string, behaving as if the field 'ball' had a null value, which is not correct in this case. The Workaround who I did was: ball := IntToStr(sqlRegister.FieldByName('ball').asInteger); My question is, Why asString should not return an empty string instead of the value '0', when the value of the register field is 0??? ---------------------------------------------------------------------- PatBayford · 2017-12-19 01:10 Is it possible that you have a setting in your database which converts 0 to null? I don't know PostgresSQL, but a lot of RDBMS systems have these sort of settings buried in the configuration! Try getting the value with AsInteger, then convert to string as a check. ---------------------------------------------------------------------- GAN · 2017-12-19 04:30 Zero may be trated as null so the empty string it's correct. To solve this, you can try StrToIntDef : http://lazarus- ccr.sourceforge.net/docs/rtl/sysutils/strtointdef.html Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function StrToIntDef(  const S: ;  Default: Integer ): Integer; Pass 0 (zero) as default. Or simple use a conditional Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if sqlRegister.FieldByName('ball').asString='' then ball:=0;