Skip to main content
1-Visitor
August 30, 2021
Solved

How to convert infotable to integer?

  • August 30, 2021
  • 1 reply
  • 1689 views

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

Best answer by PaiChung

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

1 reply

22-Sapphire I
August 30, 2021

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.

1-Visitor
August 30, 2021

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

PaiChung22-Sapphire IAnswer
22-Sapphire I
August 30, 2021

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