cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to convert infotable to integer?

YD_9850038
9-Granite

How to convert infotable to integer?

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaiChung
22-Sapphire I
(To:YD_9850038)

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

View solution in original post

3 REPLIES 3
PaiChung
22-Sapphire I
(To:YD_9850038)

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

PaiChung
22-Sapphire I
(To:YD_9850038)

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

Top Tags