Results 1 to 2 of 2

Thread: SQLite database

  1. #1
    Join Date
    Jan 2017
    Posts
    1

    Unanswered: SQLite database

    The problem i am facing is that when i delete some record from a table and enter it the serial number is behaving like a static version i.e. if i have 5 records and i delete the 5th record and then i insert a new record then the serial number assigned to it is 6 rather than 5.
    Please help if anyone know the solution to this.

  2. #2
    Join Date
    Nov 2002
    Posts
    132
    Provided Answers: 1
    It sounds as though you are referring to the value of the field which is your INTEGER PRIMARY KEY.
    That is a special type of field which auto-increments and as such its value can never be reused.

    So if you delete the record whose INTEGER PRIMARY KEY field value = 5, you will never be able to get another one.
    Instead a brand NEW record is Inserted and its INTEGER PRIMARY KEY field value is automatically one higher than the highest previous one.

    You can create a totally different field (example: RowNo) and keep track of the record count yourself via code. After the Delete you could Count the records and then on the Insert, add one to the record count and enter that as the Inserted value for the new record.

    Or, without adding another field, you can just run a SQL Query to count the records whenever you need a count.

    Good Luck

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •