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
  • 69,127
  • 105
  • 396
  • 720

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
  • 6,976
  • 5
  • 30
  • 53