JDBC 16.10: ResultSetMetaData.getColumnLabel does not return a proper column label/name

Connectivity
Connectivity covers the mechanisms for connecting to the Teradata Database, including driver connectivity via JDBC or ODBC.
Fan

JDBC 16.10: ResultSetMetaData.getColumnLabel does not return a proper column label/name

Hi all,

 

I want to generate a csv header using the information provided by the ResultSetMetaData.getColumnLabel method.

However, when I call this method the returned value is '<CASE  expression>' regardless of the column index.

 

My connection url is: jdbc:teradata://host/TYPE=FASTEXPORT,CHARSET=UTF8,COLUMN_NAME=ON

 

Any suggestions how to solve this issue?

Thanks in advance for your answers.

 

OS: Windows 7 64-Bit

JDBC driver version: 16.10.00.03

Teradata Database version: 15.10.04.06

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)


Accepted Solutions
Apprentice

Re: JDBC 16.10: ResultSetMetaData.getColumnLabel does not return a proper column label/name

Hi,

If the returned column label is '<CASE  expression>' you probably need to provide an alias for the column in your SQL.

 

So where you've currently got:

,CASE 
 WHEN test#1 THEN answer#1
 WHEN test#2 THEN answer#2 
 END

Change it to

,(CASE 
 WHEN test#1 THEN answer#1
 WHEN test#2 THEN answer#2 
 END) as column_name

What you should then find is that method returns a value of 'column_name'.

 

Cheers,

Dave

 

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com
1 ACCEPTED SOLUTION
3 REPLIES
Apprentice

Re: JDBC 16.10: ResultSetMetaData.getColumnLabel does not return a proper column label/name

Hi,

If the returned column label is '<CASE  expression>' you probably need to provide an alias for the column in your SQL.

 

So where you've currently got:

,CASE 
 WHEN test#1 THEN answer#1
 WHEN test#2 THEN answer#2 
 END

Change it to

,(CASE 
 WHEN test#1 THEN answer#1
 WHEN test#2 THEN answer#2 
 END) as column_name

What you should then find is that method returns a value of 'column_name'.

 

Cheers,

Dave

 

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com
Fan

Re: JDBC 16.10: ResultSetMetaData.getColumnLabel does not return a proper column label/name

Hi Dave,

 

thank you very much for your fast answer!

 

I was not aware of being 'COALESCE' just a 'CASE' shorthand.

Apprentice

Re: JDBC 16.10: ResultSetMetaData.getColumnLabel does not return a proper column label/name

Hi,

No problem, glad it solved your problem.

Both COALESCE and NULLIF are short forms of specific CASE functionality.

Cheers,

Dave

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com