Char(32) returning extra spaces in jdbc but not odbc

Database

Char(32) returning extra spaces in jdbc but not odbc

Any Ideas on what I'm missing?

create multiset table dlab.test as (
select cast('2' as char(32)) as label
) with no data;
insert into dlab.test values('12345678901234567890123456789012');
insert into dlab.test values('123456789012345678901234567890');


select * from dlab.test;
--returns

(Note: there are a lot of spaces in what it returns. spaces until it reaches 96 characters).

label
12345678901234567890123456789012                                                                
123456789012345678901234567890                                                                  

InfoKey InfoData
VERSION 15.00.03.03
RELEASE 15.00.03.04
LANGUAGE SUPPORT MODE Standard

 

Teradata JDBC Driver 15.10.00.14


Accepted Solutions
Teradata Employee

Re: Char(32) returning extra spaces in jdbc but not odbc

We cover this topic in the Teradata JDBC Driver User Guide:

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_5.html#BGBJECGD

 

and also in the Teradata JDBC Driver FAQ:

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/faq.html#q4

 

Using connection parameter CHARSET=UTF8 with fixed-width CHAR data type result set column values adds trailing space padding per the Teradata Database's Character Export Width behavior. If your application doesn't need the trailing space padding, you have several choices:

  • Use CHARSET=UTF16.
  • Change your query to use a CAST or TRIM to convert fixed-width CHAR data types to VARCHAR.
  • Create a wrapper view that converts fixed-width CHAR data types to VARCHAR, and query the view instead of the table.

 

1 ACCEPTED SOLUTION
3 REPLIES
Teradata Employee

Re: Char(32) returning extra spaces in jdbc but not odbc

We cover this topic in the Teradata JDBC Driver User Guide:

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_5.html#BGBJECGD

 

and also in the Teradata JDBC Driver FAQ:

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/faq.html#q4

 

Using connection parameter CHARSET=UTF8 with fixed-width CHAR data type result set column values adds trailing space padding per the Teradata Database's Character Export Width behavior. If your application doesn't need the trailing space padding, you have several choices:

  • Use CHARSET=UTF16.
  • Change your query to use a CAST or TRIM to convert fixed-width CHAR data types to VARCHAR.
  • Create a wrapper view that converts fixed-width CHAR data types to VARCHAR, and query the view instead of the table.

 

Re: Char(32) returning extra spaces in jdbc but not odbc

Thanks tomnolan, I've accept your response as the answer. However, I'm a little curious as to what exactly is "Teradata Database's Character Export Width behavior", I found that phrase in both of your links but was unable to find more information. Is it possible to change this behavoir with a config setting? Can you provide any more information on why utf8 pads fixed length columns? 

Also is there a downside to using utf16?

p.s. Some feedback for the new forums is that there is far too much spacing between lines. I feel like half of the page is white space.

Teradata Employee

Re: Char(32) returning extra spaces in jdbc but not odbc

The Teradata Database's Character Export Width behavior is documented in the Teradata Database Reference / "International Character Set Support" book / Chapter 8 "Character Conversion" / section "Working with Export Widths". All Teradata Database documentation is available form www.info.teradata.com

http://www.info.teradata.com/templates/eSrchResults.cfm?prodline=&txtpid=&txtrelno=&txtttlkywrd=TDBS...

 

Regarding too much white space in the new forum layout, I agree with you but that is outside my area of responsibility. Please post your opinion to the "Feedback" forum:

https://community.teradata.com/t5/Feedback/bd-p/BetaFeedback