cancel
Showing results for 
Search instead for 
Did you mean: 

Populate a column in table with system user by default.

former_member228804
Participant
0 Kudos

Hello Experts,

               I have created a table T1 with four fields. I want to add additional column to this table say C1 that contains the system username by default.

For this I wrote an ALTER TABLE statement as - alter table "SCHEMA"."ZDB_TEST2" add (created_by varchar(20) default system_user);

But I am getting syntax error in this case. Please guide me in order to resolve this.

Thanks in advance,

Dnyanesh

Accepted Solutions (0)

Answers (1)

Answers (1)

pfefferf
Active Contributor
0 Kudos

Hello Dnyanesh,

a function "system_user" does not exist, therefore you are getting the syntax error.

But independent of that to my knowledge up to now no option exists to use e.g. function CURRENT_USER in a CREATE or ALTER statement. According to the documentation just some date/time value functions are supported beside string and numeric literals.

ALTER TABLE - SAP HANA SQL and System Views Reference - SAP Library


<default_value_clause>  ::= DEFAULT <default_value_exp>

<default_value_exp>  ::= NULL | <string_literal> | <signed_numeric_literal> | <unsigned_numeric_literal> | <datetime_value_function>

<datetime_value_function> ::= CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP | CURRENT_UTCDATE | CURRENT_UTCTIME | CURRENT_UTCTIMESTAMP

Best Regards,

Florian

former_member228804
Participant
0 Kudos

Hello Florian,

     Thanks for your reply. I tried that as well.

alter table "SCHEMA"."ZDB_TEST2" add (created_by varchar(20) default current_user);

Still I am getting the same error.


Regards,

Dnyanesh

pfefferf
Active Contributor
0 Kudos

As I said, it is not supported until now to use CURRENT_USER as default value expression.

Best Regards,

Florian