Subject IBO + OCTETS FIELD
Author personalsoft_fabiano
Hi all,

I´m facing a strange problem when trying to store octets values in a
field. The field is declared this way:

ALTER TABLE CAD1
ADD TESTE VARCHAR(16) CHARACTER SET OCTETS;

I´m trying to store the value (an UUID) in the field this way:

Q := TIBOQuery.Create(nil);
Q.SQL.Text := 'update cad1 set teste = :teste where numcad1 = 0';
Q.ParamByName('teste').AsString :=
#$3D#$09#$AB#$34#$EF#$12#$AB#$4E#$8F#$D4#$56#$A9#$1A#$BF#$90#$1A;
Q.ExecSQL;

After i execute this query, the value stored in the database is
missing the last digit:

SQL> select teste, char_length(teste) from cad1 where numcad1 = 0;
TESTE CHAR_LENGTH
================================ ============
3D09AB34EF12AB4E8FD456A91ABF90 15

If i put a breakpoint in the line "Q.ExecSQL", i can inspect the value
stored in the param 'teste', and it is correct (with the trailing #$1A).

After some tests, it seems that if i change the last digit to values
greater than #$20, it works fine:

Q.ParamByName('teste').AsString :=
#$3D#$09#$AB#$34#$EF#$12#$AB#$4E#$8F#$D4#$56#$A9#$1A#$BF#$90#$21;
Q.ExecSQL;

SQL> select teste, char_length(teste) from cad1 where numcad1 = 0;
TESTE CHAR_LENGTH
================================ ============
3D09AB34EF12AB4E8FD456A91ABF9021 16

Do someone have a clue about what is happening, and how can i solve it?

Regards,

Fabiano