Skip to Content
Oct 22, 2020 at 03:30 PM

Is there a way to propagate Table Column Comments to Views?


Hi Hana Experts,

We are using HANA 2.0 SPS02 On-Prem edition.

Our developers are having trouble propagating Hana Table Column Comments to View Column Comments.

This is the create view documentation:

Here is the COMMENT ON documentation:

So our objective is to write views and consume the views in Calculation views and use the Comment on the column for the Calculation View's Column Label.

For Table Columns consumed in a CV, extract semantics is available to populate the labels. But for Views which have no Comments, the underlying Table Columns can not be used to extract semantics.

It's very tedious to write a view of a table with all the comments when there are multiple tables involved, which is why we want to only write the comment for the base tables and have the views auto-generate the View Column Comment.

For single table views, we can extract the comments from the underlying table with the following:

SELECT 'COMMENT ON COLUMN ' || SCHEMA_NAME || '.' || '<table_name>.' || COLUMN_NAME || ' IS ''' || COMMENTS || ''';'FROM TABLE_COLUMNS WHERE SCHEMA_NAME = '<schema_name>' AND TABLE_NAME = '<table_name>';

and re-run the COMMENT ON SQL on individual Views.

Any suggestions?