3

I'm trying to learn how to use BEGIN ... COMMIT in SQLite. I'm trying this code:

BEGIN
INSERT INTO fields VALUES ('field1')
COMMIT;

but it fails with

Error: near "INSERT": syntax error

When using just the insert statement, it succeeds, though:

INSERT INTO fields VALUES ('field1');
sashoalm
  • 75,001
  • 122
  • 434
  • 781

1 Answers1

7

Since you have it in a transaction you must end each statement with ;

BEGIN;
INSERT INTO fields VALUES ('field1');
COMMIT;
Mad Dog Tannen
  • 7,129
  • 5
  • 31
  • 55