How are you sending the commands to the cli? If you're doing...
sqlite3 myfile.sqlite ".read somefile.sql" ...then you can start the sql file with... .bail on ...and as soon as it hits an error it will stop there and not continue processing lines. So if you get rid of the "or rollback" then you'll get the error message and won't have to worry about it continuing on to the next lines in the input file despite there having been an error. And since you explicitly started a transaction it will leave the transaction open, and then when the CLI closes it will rollback the uncommitted transaction. -----Original Message----- From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> On Behalf Of Roman Fleysher Sent: Friday, June 14, 2019 2:23 PM To: General Discussion of SQLite Database <sqlite-users@mailinglists.sqlite.org> Subject: [sqlite] select within transaction Dear SQLiters, I am using sqlite3 shell. I have a transaction consisting of two commands: update and select. The idea is to get new state after update: PRAGMA busy_timeout = 50; BEGIN EXCLUSIVE; UPDATE OR ROLLBACK t SET c = 5 WHERE ...; SELECT d FROM t WHERE c = 5 AND ...; COMMIT; Is this what will happen: 1. Wait for the EXCLUSIVE lock. If not enough time, exit with error. 2. If lock obtained, attempt to update table t to set c=5. 3. Regardless (!?) if step 2 was successful or not, execute SELECT to obtain d. If update failed, then c will not be 5 (it will be old value, different from 5) and output of SEELCT will be empty. Since ROLLBACK is not an error, I want SELECT to be executed only will update actually happened (not rollback). Because of EXCLUSIVE, I want it to be in one transaction and thus I need some indicator if SELECT was after successful update, not rollback. Is this what changes() is for? Thank you, Roman _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users