0 Replies Latest reply on Jun 14, 2010 7:55 PM by ehusar

    Flex 3: Update SQLite Table Structure?

    ehusar Level 1

      I don't have any issues with creating my table when it doesn't exist but I have a quesion about updating the table structure.  For instance I want to add two new fields if they don't exist.

       

      Does anyone have an example of updating table structure?  Process flow would have to first check for table, if it doesn't exits then create it. If it does exist then check it has all the correct fields.  If it doesn't then update table structure. 

       

      Is there a built in way to do this with SQLite?

       

      Here is my current code...

       

       

      private function getRecords():void

      {

      var sqlQuery:String = "CREATE TABLE IF NOT EXISTS Roster (" +

                              "selected TEXT DEFAULT 'false' NOT NULL,"+

                              "name    TEXT        NOT NULL," +

                              "time     TEXT        NOT NULL," +

                              "gender     TEXT        NOT NULL" +

       

                              ");";

      dbStatement = new SQLStatement();

      dbStatement.itemClass = Roster;

      dbStatement.sqlConnection = exampleDB;

      dbStatement.text = sqlQuery;

      dbStatement.addEventListener(SQLEvent.RESULT, onDBStatementSelectResult);

      dbStatement.execute();

      sqlQuery= "select * from Roster";

      dbStatement.text = sqlQuery;

      dbStatement.addEventListener(SQLEvent.RESULT, onDBStatementSelectResult);

      dbStatement.execute();

      }

       

      I want to add in two new fields is possible without asking user to delete the table first.

       

                              "wins TEXT DEFAULT '0' NOT NULL," +

                              "loses TEXT DEFAULT '0' NOT NULL" +

       

      Thanks in advance.