on 10-20-2015 4:50 PM
Hi,
I'm new to SAP HANA, and know I'm facing this problem:
I've been given an entity declared like this:
Entity translation {
key id: Integer64 not null;
en: String(5000);
fr: String(5000);
de: String(5000);
it: String(5000);
es: String(5000);
zh: String(5000);
ko: String(5000);
ru: String(5000);
jv: String(5000);
ar: String(5000);
pt: String(5000);
ja: String(5000);
};
So you get the id and depending on the language that is been used, you choose one column or other
For example: we are using the language "english" (en). So I've got a global variable: var lang = "en";
Is it possible to perform a select with XSDS like this, so I choose the column i want to display depending on the variable "lang"?
var XSDS = $.import("sap.hana.xs.libs.dbutils", "xsds");
var MyEntity = XSDS.$importEntity("package", "model.translation");
// retrieve entity instance
var query = MyEntity.$query().$where(MyEntity.id.$eq(1));
var results = query.$execute();
// process result
if (results.length > 0){
$.response.setBody(JSON.stringify(results[0].lang));
}
Of course this code is wrong, but is just so you canget the idea...
Thank you very much
Hello Luis,
you can access the property by using the bracket notation in case your property name is stored in a variable.
For your example: results[0][lang]
Best 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 |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
6 | |
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.