sql事务处理回滚及保留点transaction,ROLLBACK
1BEGIN TRANSACTION
2INSERT INTO Customers(cust_id,cust_name)
3VALUES('100000010','Toys_Emporium');
4SAVE TRANSACTION StartOrder;
5INSERT INTO Orders(order_num,order_date,cust_id)
6VALUES(20100,'2001/12/1','100000010');
7IF @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
8INSERT INTO OrderItems(order_num,order_item,prod_id,quantity,item_price)
9VALUES(20010,1,'BR01',100,5.49);
10if @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
11INSERT INTO OrderItems(order_num,order_item,prod_id,quantity,item_price)
12VALUES(20010,2,'BR03',100,10.49);
13IF @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
14COMMIT TRANSACTION
2INSERT INTO Customers(cust_id,cust_name)
3VALUES('100000010','Toys_Emporium');
4SAVE TRANSACTION StartOrder;
5INSERT INTO Orders(order_num,order_date,cust_id)
6VALUES(20100,'2001/12/1','100000010');
7IF @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
8INSERT INTO OrderItems(order_num,order_item,prod_id,quantity,item_price)
9VALUES(20010,1,'BR01',100,5.49);
10if @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
11INSERT INTO OrderItems(order_num,order_item,prod_id,quantity,item_price)
12VALUES(20010,2,'BR03',100,10.49);
13IF @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
14COMMIT TRANSACTION