Jump to content

Help with transaction processing


lizzibel

Recommended Posts

Hey guys

I'm fairly new to this whole database thing, and i've hit a bit of a rut, and wondered if any of you can help me.

 

I have written the following transaction and now have to represent it in terms of read_item and write_item operations, (eg read_item(X1) etc) but have no idea how to do it because of the nested queries and the different tables that are involved. Can any of you give me a solution?

Here's the Transaction script below. Thanks. Lizzie x

 

SET AUTOCOMMIT=0;

 

START TRANSACTION;

 

SELECT AccountNo, Balance

FROM Accounts

WHERE AccountType="Current"

AND AccountNo IN (SELECT AccountNo

                  FROM AccountsXCustomers

                  WHERE CustomerNo = (SELECT CustomerNo

                                      FROM Cards

                                      WHERE CardNo=123456));

 

 

UPDATE Accounts

SET Balance=Balance-500

WHERE AccountNo IN (SELECT AccountNo

                    FROM AccountsXCustomers

                    WHERE CustomerNo = (SELECT CustomerNo

                                        FROM Cards

                                        WHERE CardNo=123456));

 

 

INSERT INTO Transactions

VALUES (700,

(NOW()),

"debit",

456134,

-500,

(SELECT AccountNo FROM Accounts WHERE AccountType="Current" AND AccountNo IN(SELECT AccountNo FROM AccountsXCustomers WHERE CustomerNo = (SELECT CustomerNo FROM Cards WHERE CardNo=123456))),

(SELECT CustomerNo FROM Cards WHERE CardNo=123456));

 

COMMIT;

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/45593-help-with-transaction-processing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.