on 11-04-2016 6:24 PM
I have .hdbtable with ID column. I need remove this column and add new with autoincrement. How can i do this?
You have to create a sequence (Create a Sequence) and determine the next value of the sequence before you insert the data. The next value can be determined using <sequence_name>.NEXTVAL.
If you wanna apply that in a xsodata service, then you have to implement a Custom Exit for Write Requests to be able to apply the logic.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would recommend to read the documentation about custom exits linked in the answer.
Following an example from the SHINE content using an XSJS function in the create before event. The XSJS function determines the next value from the sequence and sets it in the data set to be inserted.
OData service calling:
service namespace "sap.hana.democontent.epm" {
"sap.hana.democontent.epm.data::User.Details" as "Users"
create events(before "sap.hana.democontent.epm.services:userBefore.xsjslib::create_before_exit");
}
XSJS function:
function create_before_exit(param) {
var after = param.afterTableName;
var pStmt = null;
//Get Input New Record Values
try {
pStmt = param.connection
.prepareStatement('select "sap.hana.democontent.epm.data::userSeqId".NEXTVAL from dummy');
var rs = pStmt.executeQuery();
var PersNo = '';
while (rs.next()) {
PersNo = rs.getString(1);
}
pStmt.close();
pStmt = param.connection.prepareStatement("update\"" + after + "\"set PERS_NO = ?");
pStmt.setString(1, PersNo);
pStmt.execute();
pStmt.close();
} catch (e) {
pStmt.close();
}
}
Ok! I read about this. How can I apply sequence to existing column? and add data using xsodata in sapui5?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Autoincrement is not supported in the .hdbtable syntax. A workaround would be to use a sequence when inserting data.
Regards,
Florian
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 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.