Right update sql failed

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mariusz
Posts: 62
Joined: Wed 16 Jul 2008 21:04
Location: Poland / Poznan
Contact:

Right update sql failed

Post by mariusz » Mon 20 Jul 2009 12:16

I'm using sql query as follow:

update myTable set d_1=current_date, d_mod = current_timestamp, zapos = :zapos, MyMemo = (MyMemo || :TextToAdd) where nr = :nr

:zapos(VARCHAR[15])='Odbiór osobisty'
:TextToAdd(VARCHAR[27])='Towar odebrał: XXXX'
:nr(VARCHAR[10])='24899/09'
-----

It raise my application error like this

-- 2009-07-20 14:04:46:296 --
Error:
Dynamic SQL Error
SQL error code = -303
arithmetic exception, numeric overflow, or string truncation
-----

The same query with same parametres pasted in the IBExpert working fine.

I'm using IBDAC 3.0.0.3 --> TIBCQuery
Database is Firebird 2.1
MyMemo field is Varchar(4000)

I can't understand, what is wrong. Can anyone help me?

Mariusz

Archer66
Posts: 17
Joined: Wed 11 Apr 2007 14:24

Post by Archer66 » Tue 21 Jul 2009 12:52

Do You have correct charset ?

mariusz
Posts: 62
Joined: Wed 16 Jul 2008 21:04
Location: Poland / Poznan
Contact:

Post by mariusz » Tue 21 Jul 2009 19:01

I belive Yes. Other queries like
update myTable set MyMemo='Yogi Bear' working wihout a problems.

Everythings happens in big application. There is many diferent queries setting free text's in many fields. I have no problem with charset.

Archer66
Posts: 17
Joined: Wed 11 Apr 2007 14:24

Re: Right update sql failed

Post by Archer66 » Wed 22 Jul 2009 07:01

Odbiór osobisty' string has special character but 'Yogi Bear'
does not so it works even with wrong charset.

"arithmetic exception, numeric overflow, or string truncation" error message usually indicates wrong charset or that you try to post too long string or a char to a numeric field.

mariusz
Posts: 62
Joined: Wed 16 Jul 2008 21:04
Location: Poland / Poznan
Contact:

Post by mariusz » Wed 22 Jul 2009 11:56

This my delphi code:
tmp.SQL.text := 'update MyTable set MyMemo= :MyTextToAdd where nr=:nr';
tmp.ParamByName('MyTextToAdd').Text := 'ążśźćęłĄŻŚŹĆĘŁóÓ';
tmp.ParamByName('nr').Text := '6650/09/H';
tmp.ExecSQL;

This is IBCSQLMonitor's log:
-- 2009-07-22 13:52:47:046 --
update MyTable set MyMemo= :MyTextToAdd where nr=:nr
:MyTextToAdd(VARCHAR[16])='ążśźćęłĄŻŚŹĆĘŁóÓ'
:nr(VARCHAR[9])='6650/09/H'
-----
-- 2009-07-22 13:52:47:218 --
CommitRetaining:
-----

Has anyone any other idea?

mariusz
Posts: 62
Joined: Wed 16 Jul 2008 21:04
Location: Poland / Poznan
Contact:

Post by mariusz » Wed 22 Jul 2009 12:09

Archer, you puted me to the right track. The problem was with zapos field. This field is varchar[1]. I forgot to trim text length.

My fault. Thank you!

Post Reply