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

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

161 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: https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.05/en-US/20d5fa9b75191014a33eee92692f1702.html

Here is the COMMENT ON documentation: https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.05/en-US/20d3817075191014ba7bcfdbab508d0e.html

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?