Page 1 of 1

Right update sql failed

Posted: Mon 20 Jul 2009 12:16
by mariusz
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

Posted: Tue 21 Jul 2009 12:52
by Archer66
Do You have correct charset ?

Posted: Tue 21 Jul 2009 19:01
by mariusz
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.

Re: Right update sql failed

Posted: Wed 22 Jul 2009 07:01
by Archer66
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.

Posted: Wed 22 Jul 2009 11:56
by mariusz
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?

Posted: Wed 22 Jul 2009 12:09
by mariusz
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!