Firebird UTF8/WIN1250 with VarChar(2000) or more lazarus / 16-Databases ---------------------------------------------------------------------- bambamns · 2012-05-29 20:25 Hi, I'd maded FB 2.5.1 database with few tables and one of them is using filed with VarChar(2000) type and Charset/Collate WIN1250. When I define IBConnection.CharSet parametar with WIN1250 application crass with FB error : EUpdateError An error occured while applying the updates in a record: IBConnection : Execute :  -Dynamic SQL Error -SQL error code = -303 -arithmetic exception, numeric overflow, or string truncation -string right trunc If I define  IBConnection.CharSet parametar with UTF8 it works, but only if field VarChar size is less then 2000. If I put VarChar(3000) or more , with same app. it rise an error (like I wrote it) even if data for update is a few string character. I had tried different approach and defined UTF8 database an all fields with UTF8 Charset/Collate - then in Lazarus code I had to change to IBConnection.CharSet to WIN1250 - strange Even more strange is that, with this kind of settings, in field VarChar(2000) it can be written only 512 string character - no more. Any clue ? Thx ---------------------------------------------------------------------- Lacak2 · 2012-05-30 05:40 I do not have exact answer, but I guess, that situation you describe is related to how firebird client reports data length of columns (add to your example information how FreePascal transforms varchar(2000) to Field.Size? and Field.DataSize?). Basic idea is, that BYTE length and CHARACTER length are two different things. For example if you define varchar(10) with charset UTF-8 there is max.character length 10, but max.byte length is 40 (4 times more ... because one character can take up to 4 bytes in utf8 encoding). This leads to confusion also in FPC, because ATM there is no correctly distinguished between BYTE length of field buffer (DataSize property) and character length of field (Size property). ---------------------------------------------------------------------- Zoran · 2012-05-30 08:11 I have a project which uses IBConnection to access FB 2.5.1. The database is utf8 encoded. I have a field of type varchar(2000). This field is filled with mixed cyrilic and latin (including non-ascii latin characters). I have no problem to use and edit this field in application, to fill it with all 2000 characters, which takes much more than 2000 bytes (I have just tried to fill it with all - non- ascii, so it is 4000 bytes). This is tested on Windows (with both 32 bit and 64 bit firebird 2.5.1 client) and on Linux (with 32-bit client only). Lazarus 1.1 (fresh trunk), fpc 2.6.0 (stable). ---------------------------------------------------------------------- bambamns · 2012-05-30 17:28 I use following code (if it can help): Code: [Select]with LogQ do    begin     Insert;      FieldByName('ID').Value := null;      FieldByName('VREME').Value := Now;      FieldByName('THREAD').Value := _thread;      FieldByName('IP').Value := _ip;      FieldByName('LOGS').Value := logs; // VarChar(2000) - no more      Post;      ApplyUpdates;      DM.SQLTransaction.CommitRetaining;    end; Zoran(e) - Did you tried to make and fill field with more than 2000 chars like VarChar(4000) (Da li si probao da definises polje sa vecom duzinom od 2000 karaktera    ) I use Lazarus 1.1 build 37314 with FPC 2.6.1 I've found a solution - just changed chraset and collate to ISO8859_2 in database and IBConnection.Charset and it works.