You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The steps are as follows:
1, executeSql() is wrappered in promise
2, run promise( ) , then run batch( )
There was a problem with the operation:
in the database, the data insert success, but no console or alert.
if don't use promise async, sqlBatch() callback is normal
letpromise=newPromise(resolve=>{db.executeSql('SELECT count(*) AS mycount FROM DemoTable',[],function(rs){console.log('Record count (expected to be 2): '+rs.rows.item(0).mycount);resolve(true);},function(error){console.log('SELECT SQL statement ERROR: '+error.message);});})functionbatch(){db.sqlBatch(['CREATE TABLE IF NOT EXISTS DemoTable (name, score)',['INSERT INTO DemoTable VALUES (?,?)',['Alice',101]],['INSERT INTO DemoTable VALUES (?,?)',['Betty',202]],],function(){console.log('Populated database OK');alert("success")},function(error){console.log('SQL batch ERROR: '+error.message);alert("error")});}promise().then(res=>{if(res===true)batch();// batch run success, but no console or alert.the callback is invalid.})/*Ifonlybatch()isexecuted,thecallbackisverygoodsuachas*/batch();// batch run success ,console and alert is valid
The text was updated successfully, but these errors were encountered:
The steps are as follows:
1, executeSql() is wrappered in promise
2, run promise( ) , then run batch( )
There was a problem with the operation:
in the database, the data insert success, but no console or alert.
if don't use promise async, sqlBatch() callback is normal
The text was updated successfully, but these errors were encountered: