Skip to Content

CDS Defaults in Type

I have a type declared in CDS like:

type AuditT {

CreatedBy : sMedDesc;

CreatedDt : UTCDateTime;

UpdatedBy : sMedDesc;

UpdatedDt : UTCDateTime;

};

I want to set default date to CreatedDt as current datetime so that when a record is inserted if no value is passed, it should insert with default current datetime?

Any idea?

Also is there a way to specify a sequence to specific column so that on each insert it increments the value based on sequence.

I can not find these features in CDS.

Appreciate your thoughts.

Regards,

Naresh G

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jun 03, 2015 at 11:15 PM

    Sequence is not there yet in CDS , but it is possible with .hdbsequence artifact

    and to default date field, did you try like below?

    type AuditT {

    CreatedBy : sMedDesc;

    CreatedDt : UTCDateTime default CURRENT_UTCTIMESTAMP;

    UpdatedBy : sMedDesc;

    UpdatedDt : UTCDateTime;

    };

    Add comment
    10|10000 characters needed characters exceeded