Subject Conversion error in trigger
Author adam_tibor
Hello,

Can anyone tell me why do I get:
"Overflow occured during type conversion.
conversion error from string "BLOB""

I'm tracking a table's changes by creating a before update trigger.
This table has a COMMENTID that is updated in the trigger.

CREATE TRIGGER FOKONYV_BU0 FOR FOKONYV
INACTIVE BEFORE UPDATE POSITION 0
AS
declare variable vcomment varchar(8192);
declare variable vusername varchar(40);
declare variable vstring varchar(80);
declare variable vdatetime char(24);
begin
vdatetime = cast(current_timestamp as timestamp);
select fullname from users where userid=new.userid into :vusername;

if (old.commentid <> 0) then
begin
select comment from comments where commentid = old.commentid
into :vcomment;
vcomment = vcomment || ascii_char(13);
/* if this is not the first update of the record, then I get the
content of the earlier comments into vcomment. Then later in this
trigger I just add the next change as below..*/
end
else vcomment = ''; /* if this is the first update of the record,
than vcomment should start as an empty string */

vcomment = vcomment || '--> Bejegyzés szerver oldali idõpontja: '
|| :vdatetime;
vcomment = vcomment || ascii_char(13) || :vusername || ' a
következõ mezõket módosította:';

if ((old.userid) <> (new.userid)) then
begin
select fullname from users where userid=old.userid
into :vusername;
vcomment = vcomment || ascii_char(13) || ' - elõzõleg
módosította: ' ||:vusername;
end

.... /* there are some other checkings and adding further text to
the vcomment */

if ((old.befnev) <> (new.befnev)) then vcomment = vcomment ||
ascii_char(13) || ' - elõzõ befizetõ: ' || old.befnev;
if ((old.osszeg) <> (new.osszeg)) then vcomment = vcomment ||
ascii_char(13) || ' - elõzõ összeg: ' || cast(old.osszeg as integer);
if ((old.afa) <> (new.afa)) then vcomment = vcomment || ascii_char
(13) || ' - elõzõ ÁFA kulcs: ' || cast(old.afa as float);

if (old.commentid <> 0) then
begin
update comments set comment = :vcomment
where commentid = old.commentid;
/* if there is already a comment for this record, so this is not
the first update, then updating..*/
end else
begin
insert into comments (comment) values (:vcomment);
new.commentid = gen_id(gen_commentsid,0);
/* if this is the first update of the rekord, then inserting a
new rekord into COMMENTS table and getting the COMMENTID by gen_id */
end
end

CREATE DOMAIN TTEXT AS
BLOB SUB_TYPE 1 SEGMENT SIZE 80 CHARACTER SET WIN1250

CREATE TABLE COMMENTS (
COMMENTID INTEGER NOT NULL,
COMMENT TTEXT)

BTW, the database's default character set is WIN1250

Comments should look like this (after two updates):
--> Bejegyzés szerver oldali idõpontja: 2005-01-23 15:17:28.0000
A felhasználó módosította: Ádám Tibor (fejlesztõ). A következõ mezõk
változtak:
- elõzõleg módosította: Ádám Tibor (fejlesztõ)
- elõzõ kelte: 2004-01-12
- elõzõ irány: bevétel
- megjelölés státusza: nem megjelölt
- törlés státusza: aktív rekord

--> Bejegyzés szerver oldali idõpontja: 2005-01-23 15:17:28.0000
A felhasználó módosította: Ádám Tibor (fejlesztõ). A következõ mezõk
változtak:
- elõzõleg módosította: Ádám Tibor (fejlesztõ)
- elõzõ kelte: 2004-01-12
- törlés státusza: aktív rekord


Thank you for your respone,
Tibor Adam