As convert a database query to an integer?

You must Login before you can answer or comment on any questions.

I have a query to a database that should give me a number I want to know how to convert it to number in "Titanium", I want to use that as a reference number for another search in the database in another table, This is my code: var registros= dbPostal.execute("SELECT * FROM catalogoCP WHERE cp=?", cp); if(registros.getRowCount() > 0) {

cpInfo['estadoid']= registros.fieldByName('estadoid');
cpInfo['municipio']= registros.fieldByName('municipio').toString();
cpInfo['claveMunicipio'] = registros.fieldByName('claveMunicipio');
cpInfo['municipioid']= registros.fieldByName('municipioid').toString();
cpInfo['nombre'] = registros.fieldByName('nombre').toString();
registros.next();

registros= dbPostal.execute("SELECT * FROM conapo WHERE entidadid=? AND municipioid=? ORDER BY nombreLocalidad ASC", cpInfo['estadoid'],cpInfo['municipioid']);

while(registros.isValidRow()) {

cpInfo['nomloca']= registros.fieldByName('nombreLocalidad').toString();
cpInfo['clalo']= registros.fieldByName('claveLocalidad');
registros.next();

}

2 Answers

Accepted Answer

Also, to answer your actual question, Titanium uses Javascript, so converting numbers is the same as Javascript. Number function

Seems to me like you actually want to do just one query with a JOIN.

SELECT * FROM catalogoCP cp JOIN conapo c ON (c.entidadid = cp.estadoid AND c.municipioid = cp.municipioid) WHERE cp.cp = ? ORDER BY c.nombreLocalidad ASC

— answered 7 months ago by Shannon Hicks
answer permalink
1 Comment
  • I want what this ....................................................................................................................................... registros= dbPostal.execute("SELECT * FROM conapo WHERE entidadid=? AND municipioid=? ORDER BY nombreLocalidad ASC", cpInfo['estadoid'],cpInfo['municipioid']);................................................... cpInfo['estadoid'],cpInfo['municipioid']); I want These 2 are converted to an integer

    — commented 7 months ago by Victor Santillan

Your Answer

Think you can help? Login to answer this question!