Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti mustaqil ish



Yüklə 135,9 Kb.
səhifə7/7
tarix16.12.2023
ölçüsü135,9 Kb.
#183164
1   2   3   4   5   6   7
enbmbbmi

COMMIT amalinining qo`llanilishi
-- Start a transaction
BEGIN TRANSACTION;

-- SQL statements within the transaction


UPDATE table_name SET column1 = value1 WHERE condition;
INSERT INTO table_name (column1, column2) VALUES (value1, value2);

-- Commit the transaction to make changes permanent


COMMIT;
-- Start a transaction
BEGIN TRANSACTION;

-- Update the version number of software with ID 1


UPDATE Software SET version_number = '2.0' WHERE software_id = 1;

-- Commit the transaction to make the change permanent


COMMIT;

Rollback amalini bajarilishi
-- Start a transaction
BEGIN TRANSACTION;

-- Update the version number of software with ID 1


UPDATE Software SET version_number = '2.0' WHERE software_id = 1;

-- Check for a condition (this could be an error check)


IF some_condition THEN
-- Rollback the transaction to undo the changes
ROLLBACK;
ELSE
-- Commit the transaction to make the change permanent
COMMIT;
END IF;
-- Start a transaction
BEGIN TRANSACTION;

-- Update the version number of software with ID 1


UPDATE Software SET version_number = '2.0' WHERE software_id = 1;

-- Check for a condition (this could be an error check)


IF some_condition THEN
-- Rollback the transaction to undo the changes
ROLLBACK;
PRINT 'Transaction rolled back.';
ELSE
-- Commit the transaction to make the change permanent
COMMIT;
PRINT 'Transaction committed.';
END IF;


SAVEPOINT tranzaksiyasini ishlatilishi

-- Start a transaction


BEGIN TRANSACTION;

-- Update the version number of software with ID 1


UPDATE Software SET version_number = '2.0' WHERE software_id = 1;

-- Create a savepoint


SAVEPOINT my_savepoint;

-- Attempt to update another software record


UPDATE Software SET version_number = '3.0' WHERE software_id = 2;

-- Check for a condition (this could be an error check)


IF some_condition THEN
-- Rollback to the savepoint
ROLLBACK TO my_savepoint;
PRINT 'Rolled back to savepoint.';
ELSE
-- Commit the transaction to make the change permanent
COMMIT;
PRINT 'Transaction committed.';
END IF;
-- Start a transaction
BEGIN TRANSACTION;

-- Update the version number of software with ID 1


UPDATE Software SET version_number = '2.0' WHERE software_id = 1;

-- Create a savepoint


SAVEPOINT my_savepoint;

-- Attempt to update another software record


UPDATE Software SET version_number = '3.0' WHERE software_id = 2;

-- Check for a condition (this could be an error check)


IF some_condition THEN
-- Rollback to the savepoint
ROLLBACK TO my_savepoint;
PRINT 'Rolled back to savepoint.';
ELSE
-- Commit the transaction to make the change permanent
COMMIT;
PRINT 'Transaction committed.';
END IF;
Yüklə 135,9 Kb.

Dostları ilə paylaş:
1   2   3   4   5   6   7




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin