Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"BEGIN..COMMIT;" fails in SQLite

Tags:

sql

sqlite

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');
like image 451
sashoalm Avatar asked Jun 27 '26 02:06

sashoalm


1 Answers

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

BEGIN;
INSERT INTO fields VALUES ('field1');
COMMIT;
like image 75
Mad Dog Tannen Avatar answered Jun 29 '26 16:06

Mad Dog Tannen