Quantcast
Channel: SCN: Message List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 8968

Creating a default column to store current user?

$
0
0

Hi

 

I need to create two columns to automatically keep track of the current time stamp and current user information for each row operation. I have tried the following schema to achieve this:

 

"LAST_MODIFIED" LONGDATE CS_LONGDATE NOT NULL GENERATED ALWAYS AS CURRENT_TIMESTAMP,

"LAST_UPDATED_BY" NVARCHAR(100) NOT NULL GENERATED ALWAYS AS CURRENT_USER,

 

Internally, HANA creates two ALTER statements for the above "generated always columns":

 

ALTER TABLE "TRNFRM_DWUSAGE"."TEST_MEM" WITH PARAMETERS ('CONCAT_ATTRIBUTE'=('EXPRESSION=longdate( now() )',

           'LAST_MODIFIED'));

 

ALTER TABLE "TRNFRM_DWUSAGE"."TEST_MEM" WITH PARAMETERS ('CONCAT_ATTRIBUTE'=('EXPRESSION=''hana_user''',

           'LAST_UPDATED_BY'));

 

I have no issue with current timestamp as it gets generated as "now()". However, current user value gets hard coded to the current value defying the purpose of  generated always column. i.e, if some other user performs a row operation, the LAST_UPDATED_BY column will not get updated. Please let me know if there is any workaround.

 

Also, can someone plz  point me to the documentation of ALTER statement which uses WITH PARAMETERS and CONCAT_ATTRIBUTE ?


Viewing all articles
Browse latest Browse all 8968

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>