Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.