re write-sql statement Insert OR REPLACE from java to c++ NDK Android -


i need re write sqlite statements java c++, becouse of low performance: red arcticle:

improve insert-per-second performance of sqlite?

but iam totaly confused, becouse cant find sqlstatemenst of insert or update

 public synchronized void savematchvalue(int photorecowner, int[] photorecassign, float[] value) {     sqlitedatabase database = databasehelper.getwritabledatabase();     database.begintransaction(); 

in java:

      string sql = " insert or replace " + typecontract.ctablephotomatch.table_name + "("             + typecontract.ctablephotomatch.fk_owner + "," + typecontract.ctablephotomatch.fk_assign + ","             + typecontract.ctablephotomatch.value + ") values (?, ?, ?) ;"; 

// can same in c++?

         string sqlstatement = "insert abe_account ("........... 

and rest clear me plus minus // it

    sqlitestatement stmt = database.compilestatement(sql);       // stmt.binddouble(index, value);     // database.compilestatement(sql)     try {         string[] whereargs = new string[2];         int rows = 0;         (int = 0; < photorecassign.length; i++) {              if (photorecowner > photorecassign[i]) {                 stmt.binddouble(1, photorecowner);                 stmt.binddouble(2, photorecassign[i]);               } else {                 stmt.binddouble(1, photorecassign[i]);                 stmt.binddouble(2, photorecowner);               }             stmt.binddouble(3, value[i]);              try {                 long entryid = stmt.executeinsert();             } catch (exception e) {                 // updtstmt.executeupdatedelete();             } {                 stmt.clearbindings();              }             // contentvalues contentvalues = crosstablecontentvalues(             // photorecowner, photorecassign[i], value[i]);             // database.insert(typecontract.ctablephotomatch.table_name,             // null,             // contentvalues);         }         database.settransactionsuccessful();     } {         stmt.close();          database.endtransaction();         // database.close();     } } 

you can use std::to_string build string using variables

#include <string> std::string sql = " insert or replace " + std::to_string(typecontract.ctablephotomatch.table_name) + "(" + ...; 

if of variables std::string, don't need use function can use + concatenate.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -