0 Replies Latest reply on Feb 28, 2011 3:05 PM by Fran711

    How to get SQLite DB to go to beginning of DB on hit MAX ID




      I'm making a small mobile app that uses an SQlite database.  The idea is that the user clicks the 'next record' button and the next record (by incrementing the id 1) is brought up on the screen.  However, when the user reaches the last record and clicks 'next' right now, there is a run-time error saying that the record cannot be found (makes sense).


      What I can't figure out for the life of me is how to get the database to go back to the first record when the max_id is currently displayed.  Any advice would be wonderful.  Thanks alot!


      Here is what I'm currently trying which doesn't work:


      private function nextMoveLPart(event:EffectEvent):void
                          var cardNumber:int = parseInt(cardNumberLabel.text);
                          stmtB.sqlConnection = connB;
                          stmt.text = "IF(id != MAX(id)) BEGIN SELECT * FROM cardItems WHERE id = ?" + " END ELSE BEGIN SELECT MIN(id) FROM cardItems END";
                                      stmtB.parameters[0] = cardNumber-1;
                          stmtB.addEventListener(SQLEvent.RESULT, resultHandlerPrev);