Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello Experts,
I have some sql queries that retrieve data from DB and by default it accepts as base type of the output only an infotable, i would like to convert the output to integer!!
Regards,
Youss
Solved! Go to Solution.
First make sure you assign an appropriate datashape or know the columns of your query output (looks like you are getting one column: 'idusuario')
So in your wrapper service, you'll have to do something like:
try {
var SqlQueryResult = me.queryUserByIdCard({
idTarjeta: idTarjeta /* INTEGER */
});
//At this point SqlQueryResult is still an integer
//Now generate your Integer result
var result = SqlQueryResult.idusuario;
//Make sure your output type of this wrapper service is set to Number or Integer
}
Hope that helps
Wrap the SQL service with a JS service that invokes the SQL services and takes the returned infotable, extracts the value and returns it as an integer.
I have this service that execute the query:
try {
var queryUser = "SELECT idusuario FROM usuario where idtarjeta="+idTarjeta;
logger.debug("DatabaseController.JavaScriptQuery_TablaUsuario(): Query - " + queryUser);
var result = me.RunDatabaseQuery({query:queryUser});
} catch(error) {
logger.error("DatabaseController.JavaScriptQuery_PersonsTable(): Error - " + error.message);
}
It returns an infotable as output!
I have another service where i am trying to do something like:
try {
var SqlQueryResult = me.queryUserByIdCard({
idTarjeta: idTarjeta /* INTEGER */
});
} catch(error) {
logger.error("DatabaseController.JavaScriptQuery_PersonsTable(): Error - " + error.message);
}
So i assign the output of queryUserByIdCard to SqlQueryResult but i still is an infotable, i dont see how i can do, do you have an idea?.
Thanks,
Yous
First make sure you assign an appropriate datashape or know the columns of your query output (looks like you are getting one column: 'idusuario')
So in your wrapper service, you'll have to do something like:
try {
var SqlQueryResult = me.queryUserByIdCard({
idTarjeta: idTarjeta /* INTEGER */
});
//At this point SqlQueryResult is still an integer
//Now generate your Integer result
var result = SqlQueryResult.idusuario;
//Make sure your output type of this wrapper service is set to Number or Integer
}
Hope that helps