Jump to content

Stop transaction if bank account not found


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...