on 07-31-2013 11:24 PM
I've created an hdbtable artifact witht the following definition:
table.schemaName = "MYSCHEMA";
table.tableType = COLUMNSTORE;
table.description = "Demo";
table.columns = [
{name = "DriverId"; sqlType = INTEGER; nullable = false; comment = "Driver ID";},
{name = "DriverName"; sqlType = NVARCHAR; nullable = false; length = 50; comment = "Driver Name";},
];
table.primaryKey.pkcolumns = ["DriverId"];
I want to add another column of type TIMESTAMP and want it to have a default value of CURRENT_TIMESTAMP whenever you change the row. I can't seem to figure out how to do that in my hdbtable artifact
Basically I'm looking to do the same thing as this SQL statement:
CREATE COLUMN TABLE DRIVERS (
DriverId INTEGER NOT NULL,
DriverName NVARCHAR(50) NOT NULL,
last_modified TIMESTAMP GENERATED ALWAYS AS CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (DriverId)
);
Can anyone please help me out? Thx!
An alternative to GENERATED ALWAYS AS for SQL is to use the CURRENT_TIMESTAMP function as the default value.
Check Ravindra's message in this thread: http://scn.sap.com/message/13851078#13851078
You could try it in the defaultValue parameter of the table definition, but I'm not sure it'll work, tho.
I suppose XS will try to interpret "current_timestamp" as a string instead of a function name. 😕
Best,
Henrique.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you everyone for your help. After doing lots of digging around, I don't think it's possible to use GENERATED ALWAYS AS in the .hdbtable file. As a workaround, I'm using a SQL script that adds the column to the table with the required column definition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you need this column to show the time of change then you will have to populate it during the load using now() (or another function that sets the current time depending on which platform you are using for data load).
GENERATE ALWAYS AS columns are generated everytime you request the data (select). So it will show you timestamp of the select, not update.
Regards,
Zafer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.