Problem inserting byte data

Database
Enthusiast

Problem inserting byte data

Hi All,

In TD 13.10, i need load data from hexa chars to another table in a byte column.

CREATE SET TABLE SYSDBA.sample ,NO FALLBACK ,NO BEFORE JOURNAL,NO AFTER JOURNAL,

CHECKSUM = DEFAULT,DEFAULT MERGEBLOCKRATIO

X CHAR(10),

Y BYTE(40))

PRIMARY INDEX sample (X);

When i make :

INSERT INTO SYSDBA.sample

SELECT 'z', '00004147F2CE2AD9AB4D7E5BF94650EEDD4A58D5'XB

this work fine.

But when i get the data from a select :

INSERT INTO SYSDBA.sample 

SELECT 'z', o.x

FROM SYSDBA.origin o

or this

INSERT INTO SYSDBA.sample 

SELECT 'z', o.x || 'XB'

FROM SYSDBA.origin o

recieve an error : 3532 : Conversion between BYTE data and other types is illegal

any suggestions ?

2 REPLIES
Enthusiast

Re: Problem inserting byte data

Anyone can help ?

Teradata Employee

Re: Problem inserting byte data

The built-in function TO_BYTES was introduced in Teradata Database 14.0 and it provides conversion from a VARCHAR value consisting of hexadecimal digits to a VARBYTE value. (It can also do other conversions.)

Teradata Database 13.10 doesn't have a built-in function to do what you need.

As a workaround, you can query the data and format each row of the data as an INSERT command:

select 'insert into Destinationtable(DestinationByteColumn) values(''' || SourceCharColumn || '''xb);' from SourceTable;

saving the query output to a file, which you subsequently run as a BTEQ script.