Convert Varbyte to Character

Database
Enthusiast

Convert Varbyte to Character

I would like to convert the Hostdata column from a TPUMP error table from varbyte to character. I found a UDF (VarbyteToVarchar.c) which said it would do it but I haven't had any luck calling it.
5 REPLIES
Teradata Employee

Re: Convert Varbyte to Character

The HOSTDATA column contains whatever bytes the client sent. If there is character data, it will be in the client characterset so using a UDF to (in effect) just declare it LATIN or UNICODE probably won't do what you intend; there could also be binary data, length fields, etc. The best alternative may be to export the data back to the originating client platform for viewing.
Enthusiast

Re: Convert Varbyte to Character

Thanks very much for your input but I don't understand why a platform change would help me translate the data in the Hostdata field. I know I can move the data to my local machine and view a record at a time but I would like to read the data in a stored procedure and look for some key fields. It seems that if I could move it from the database to my client and read it I should be able to read it on the database. Of course I know there might be exceptions but it has been able to translate most of it on the client.
Teradata Employee

Re: Convert Varbyte to Character

Actually the point of moving the data back to the original platform is that the data is NOT translated. (It remains in client format even in the error table field; that's why it's typed VARBYTE - so no translation occurs.)

Yes, it should be possible to use functions (UDFs, SUBSTRING, etc.) to look for specific data within the field and do some type conversions.

If your character fields are coming from a network-attached client and using only basic (printable unaccented alphanumeric) characters, those probably map directly to internal LATIN or UNICODE representation so a VarbyteToVarchar type UDF should be useful for that. But if you use extended characters (or mainframe EBCDIC) it's a little more challenging...

And if the client is sending numeric fields you'll need to be careful about things like byte order (big-endian vs. little-endian) when doing those conversions.
Enthusiast

Re: Convert Varbyte to Character

Hi JPORELL/FRED,

I know this post was back in 2006, but I'm really in search of a UDF or some method within teradata to convert varbyte to varchar. So I'm hoping you guys can help me out.

My primary objective is to store all rows in the error table of fastload into a persistent error table(its ddl matches with that of the target table but all fileds are varchar)

I could do the method of exporting the records of error table into the client system and read them back again into a table with all varchar but all of this seems unnecessary(and franky quite crude) to me.

I'd like a method to keep the record within teradata itself and achieve this objective. We're on TD 13.10.

Regards,

Suhail

Enthusiast

Re: Convert Varbyte to Character

Anyone? Can I get a copy of the function: VarbyteToVarchar.c? I can't seem to find it anywere on the internet.

Regards,

Suhail