Start a new topic
Answered

Renaming columns on select during export

When using @export the columns I've renamed within the select statement revert back to the actual column names of the table, and not the custom values I'm setting.  e.g.


@export on;
@export set filename="C:\file.json" format="json";
SELECT DOCUMENT_ID as "documentId"
FROM TABLE_NAME;
@export off;


The exported results show "DOCUMENT_ID" as the column, not "documentId".


If I remove the @export annotations, the grid shows the custom column names (documentId).  Is this a limitation with @export where custom column names cannot be set?


Best Answer

Hi Justin,


I've tested with DB2 9.1 (I don't have access to 9.5) and the bundled JDBC driver (4.22.29). 


By default, I get the column name as the grid header even when I specify an alias for a column. I need to set the useJDBC4ColumnNameAndLabelSemantics driver property to false in order to get the alias as the grid header.


When I use @export with the JSON format, I always get the same value as the grid header, i.e. either the column name or the alias depending on the value of the driver property.


Are you using a different JDBC driver version? Do you specify any driver properties?


If this doesn't help, please open Tools->Debug Window and enable debugging for DbVisualizer run the @export again. Then open Help->Contact Support to send a support request, making sure that Attach Logs is enabled. This way we get more info to help figure out what may be wrong.


Best Regards,

Hans



Hi Justin,


It works for me with a Sybase ASE 16 database. Which database do you use?


Best Regards,

Hans

Thanks for the reply Hans.


We're using DB2 v9.5.  The column names are adjusted just fine in the grid view, but when using @export they are the defaults that I'm trying to rename.

Answer

Hi Justin,


I've tested with DB2 9.1 (I don't have access to 9.5) and the bundled JDBC driver (4.22.29). 


By default, I get the column name as the grid header even when I specify an alias for a column. I need to set the useJDBC4ColumnNameAndLabelSemantics driver property to false in order to get the alias as the grid header.


When I use @export with the JSON format, I always get the same value as the grid header, i.e. either the column name or the alias depending on the value of the driver property.


Are you using a different JDBC driver version? Do you specify any driver properties?


If this doesn't help, please open Tools->Debug Window and enable debugging for DbVisualizer run the @export again. Then open Help->Contact Support to send a support request, making sure that Attach Logs is enabled. This way we get more info to help figure out what may be wrong.


Best Regards,

Hans


Hans,


Updating the useJDBC4ColumnNameAndLabelSemantics driver property to false did the trick for me, even though the grid was already showing the alias names.  I wouldn't have figured that out in a hundred years otherwise, so thank you!


Justin

Justin,


Just to let you know there will be the new JSONColumnHeaderIsColumnAlias="<true/false>" parameter for @export set in the upcoming 10.0 version. You then don't need to set the useJDBC4ColumnNameAndLabelSemantics driver property.


Regards


Roger

Justin,


We just released DbVisualizer 100.2718, a beta version of the upcoming 10.0. It includes support for the new JSONColumnHeaderIsColumnAlias setting.


You may give the beta a try by download here: http://www.dbvis.com/download/beta/


Regards


Roger


 

Justin,


Just to inform you that we've released DbVisualizer 10.0.


Use Help->Check for Update in DbVisualizer to install the new version or visit the download page on our web. The Check for Update will also indicate whether 10.0 is a free upgrade.


Regards


Roger

Login or Signup to post a comment