Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Default values in XSDS

$
0
0

Hello all,

 

I've been looking for some examples about the topic, but found nothing...

 

Is there a way to use the default value when creating an instance via XSDS?

 

For example:

 

  @Catalog.tableType: #COLUMN

Entity user {

key id: Integer64 not null;

role: hana.SMALLINT not null default 2;

first_name: String(50) not null;

last_name: String(50) not null;

email: String(50) not null;

username: String(50) not null;

password: String(50) not null;

language_code: Association to modelo.language { code } not null;

nb_login: Integer64 not null default 0;

status: hana.SMALLINT not null default 0;

user_id: Integer64;

date: UTCTimestamp not null;

};

 

If I don't specify the value of nb_login, like I would do if i were making an insert via SQL console...y get an error

 

 

var lang = langEntity.$get({ code: 'es' });

           var user = new userEntity({ id: 4, role: 2, first_name: 'Luiasds', last_name: 'lastasdName', email: 'emasail',

           username: 'username', password: 'password', language_code: lang ,  status: 0,user_id: userId, date: new Date() });

          

user.$save();

 

 

cannot insert NULL or update to NULL: Not nullable "nb_login" column

 

So I would like to put the default value 0, is there any way of giving it (apart of typing "nb_login: 0" in the set of values when creating it, of course)

 

What is the point of a default value then?

 

 

Best regards,

 

Luis


Viewing all articles
Browse latest Browse all 6412

Trending Articles