Search code examples
sqlitetransactions

Unable to Start Simple Transaction in SQlite


I have started SQlite 2-days ago, and today i tried to learn Transactions in Sqlite3. But i am unable to even run the simplest ever transaction.

Begin;
Insert into newTable(Name,Age) values ("Adnan Ahamd KHan",24)
Insert into tbl2 (Name, FID) values ("Adnan",(Select MAx(ID) from newTable))
END Transaction;

Error Displayed is

cannot start a transaction within a transaction: Begin;

Solution

  • Here we go,
    I found the answer to my Questio. Actually i am using DBBrowser for SQlite. And upto my knowledge, you have to commit every statement in DBBrowser for SQlite. I First created Tables, established Relationship, and without committing them all, i then tried to start that Transaction, that's why it was saying

    cannot start a transaction within a transaction: Begin;
    

    What i did, first issued a single

    commit
    

    to commit the statements which created tables, and then started Transaction. And it worked fine.

    Thanks