on 2015 Jun 03 11:12 PM
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
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;
};
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll say up front that my system is running an early version of SPS 10 and there will be lots of extensions to CDS in SPS 10 for better integration of standard SQL functions. That said, I'm able to use the CURRENT_UTCTIMESTAMP as the default just fine in my system. Looks like this is a feature which is coming soon.
namespace playground;
@Schema: 'PLAYGROUND'
context scn {
@Catalog.tableType: #COLUMN
entity Users {
key ID : Integer;
Name : String(20) not null;
updatedDt: UTCDateTime default CURRENT_UTCTIMESTAMP;
};
};
User | Count |
---|---|
70 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.