I was looking for an example of data consistency over tables by using ACID transaction. I saw the example here : http://microservices.io/patterns/data/shared-database.html summery is as follow: CUSTOMER table has a column CREDIT_LIMIT. we want to insert into ORDER table a new record If OrderPrice< CREDIT_LIMIT of that user. Written query in the example is as follow and I believe it is not complete:
BEGIN TRANSACTION
SELECT ORDER_TOTAL
FROM ORDERS WHERE CUSTOMER_ID = 123
SELECT CREDIT_LIMIT
FROM CUSTOMERS WHERE CUSTOMER_ID = 123
INSERT INTO ORDERS
COMMIT TRANSACTION
According to the tutorial, to keep data consistency over 2 tables, there should be an "If check" in query. Anyone can complete the query ? I would appreciate.