Jump to content

Stop transaction if bank account not found


philirving
 Share

Recommended Posts

I want to NOT complete the transaction if there is no record with AcctNum="1001". For instance:
begin transaction; update Accounts set Bal=Bal-250 where AcctNum="1001"; update Accounts set Bal=Bal+250 where AcctNum="2002"; commit transaction

When I do this (in SQLite) AcctNum 2002 gets the 250 even if there is no record AcctNum="1001". How can I stop the transaction, and perhaps show an error message? 

Very simple table to test with: create table [Accounts] ( [AcctNum] char[4] primary key not null, [Bal] real ) ; insert into Accounts values ("2002",500.0); insert into Accounts values ("2005",250.0) ; 

Thanks in advance.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...