1001 Things You Wanted To Know About Visual FoxPro phần 7

Tham khảo tài liệu '1001 things you wanted to know about visual foxpro phần 7', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 8 Data Buffering and Transactions 273 if the order could not be added. A single transaction is not enough but a pair of nested transactions will meet the bill very well as illustrated below Start the outermost Wrapper transaction BEGIN TRANSACTION Update the Customer table first llTx1 TableUpdate 1 .F. customer IF llTx1 Customer table updated successfully Start the second inner transaction for Orders BEGIN TRANSACTION llTx2 TableUpdate 1 .F. orderheader IF llTx2 Orders Updated now try details llTx2 TableUpdate 2 .F. orderdetails IF llTx2 Both Order tables updated successfully So commit the orders transaction END TRANSACTION ELSE Order Detail update failed Roll back entire orders transaction ROLLBACK ENDIF ELSE Order Header update failed - no point in trying details ROLLBACK ENDIF But the customer update had already succeeded so commit END TRANSACTION ELSE Customer update failed - no point in proceeding ROLLBACK ENDIF This code may look a little strange at first sight but does emphasize the point that TRANSACTION does not constitute a control structure. Notice that there are two starting commands one for each transaction and two Commit commands one for the customer table and one for the pair of order tables. However there are three rollback commands. One for the outer transaction but two for the inner transaction to cater to the fact that either table involved might fail. The logic gets a little more tricky as more tables are involved but the principles remain the same. However when many tables are involved or if you are writing generic routines to handle an indeterminate number of tables at each level it will probably be necessary to break the transactions up into separate methods to handle Update Commit and Rollback functions 274 1001 Things You Always Wanted to Know About Visual FoxPro and to use the TXNLEVEL function to keep track of the number of transactions. Remember that Visual FoxPro is limited to five simultaneous transactions. Some .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
46    110    3    22-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.