Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Database Creation Issues in SAPUI5 applicatoin

Hi All,

        I'm creating database in sapui5 application for registration screen. Database is created once the button is clicked. But i want to check the details once the app open if already the customer register means i moves to login screen. So i want to call the database creation function in init function i tried but it does not populate. I share my code snippet here please correct it. Thanks in advance.



  // Populate the database

     function populateDB(tx) {

      alert("Registration_Key : "+registration_Key);

          tx.executeSql('DROP TABLE IF EXISTS DEMO');

         tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');      

         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, 2)');




     function queryDB(tx) {


         tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);



     // Query the success callback

     function querySuccess(tx, results) {

      alert("querySuccess: "+querySuccess);

         var len = results.rows.length;

         console.log("DEMO table: " + len + " rows found.");

         for (var i=0; i<len; i++){

             console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).data);



     // Transaction error callback

     function errorCB(err) {

         console.log("Error processing SQL: "+err.code);

         alert("Error processing SQL: "+err.code);


     // Transaction success callback

     function successCB() {


         var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);

         db.transaction(queryDB, errorCB);


  alert("First Key : "+registration_Key);

  registration_Key = "Registered";

  db.transaction(populateDB, errorCB, successCB);


  onInit: function() {



Not what you were looking for? View more on this topic or Ask a question