SQL tilindetranzaksiya processine misal. SQL tilinde hár bir tranzaksiya bir toliq processti orinlawǵa túsinik payda ettik .Mine usinday processke missal keltiremiz:
“Ta'minlovchilar”kestesindegi Sxnomerin Sy nomerineózgertiw lazim bolsin. Sx va Sy - berilgen aniq parametr.
TRANEX: PROC OPTIONS (MAIN); /* tranzaksiyaǵa misal*/
EXEC SQL WNENEVER SQLERROR GO TO UNDO;
GET LIST (SX,SY);
EXEC SQL UPDATE S
SET TÁMINLOVCHI RAQAMI = SY WHERE TÁMINLOVCHI RAQAMI = SX;
EXEC SQL UPDATE SP
SET TÁMINLOVCHI RAQAMI = SY WHERE TÁMINLOVCHI RAQAMI = SX;
EXEC SQL COMMIT;
GO TÓFINISH;
UNDO: EXEC SQL ROLLBACK;
FINISH: RETURN;
END TRANEX;
Misalimizdan kórinip turǵaninday, bul tranzaksiya processinde eki keste ishinde ózgerisler ámelge asirilip atir. Demek, tranzaksiya degenimizde bir ámeldi emes, balkim ámeler izbe- izligin túsiniw lazim.
2. SQL ortaliǵinda tranzaksiyardi basqariw. SQL tilin de tranzaksiyalardiarnawli operatorlar járdeminde basq1ariw imkaniyati bar. Solardan biri tranzaksiya parametrlerin ornatiw operatorı bolıp. Onı
Jaziw formati tómendegishe:
::=
SET TRANSACTION transaction mode>
[ { transaction mode> }... ]
transaction mode> ::=
| | «diagnostics size>
«isolation level> ::=
ISOLATION LEVEL «level of isolation>
::=
READ UNCOMMITTED | READ COMMITTED i REPEATABLE READ | SERIALIZAB1 1
transaction access mode>
READ ONLY | READ WRITE
diagnostics size> ::=
DIAGNOSTICS SIZE ::= Bul jerde:
Eger qorǵaw dárejeleri kórsetilmese , qorǵaw dárejesi SERIALIZABLE deb túsiniledi.
Eger ruxsat tartipli READWRITE gilit sózi menen belgilense, onda qorǵaniw dárejesi READUNCOMMITTED bolmawi kerek.
Eger ruxsat tartibi hám qorǵaniw dárejesi READUNCOMMITTED deb kórsetilse, onda beriletuǵin ruxsat tartipli READONLY deb tusiniledi, basqa halatta ruxsat tartibi READWRITE boladi.
SELECT a.snum, sname, onum, ’Highest oń, odate FROM Salespeople a. Orders b WHERE a.snum = b.snum
AND b.amt = (SELECT MAX (amt) FROM Orders сWHERE c.odate = b,odate)
UNION
SELECT a.snum, sname, onum, ’Lowest oń, odate FROM Salespeople a, Orders b WHERE a.snum b.snum
1001
Peel
3008
Highest
on
10/05/2012
1001
Peel
3008
Lowest
on
10/05/2012
1001
Peel
3011
Highest
on
10/06/2012
1002
Serrea
3005
Highest
on
10/03/2012
1002
Serres
3007
Lowest
on
10/04/2012
1002
Serres
3010
Lowest
on
10/06/2012
1003
Axelrod
3009
Highest
on
10/04/2012
1007
Rifкд.п
3001
Lowest
on
10/03/2012
AND b.amt = (SEi FCT MIN (amt)FROM Orders сWHERE c.odate ; b.odate);
Usi waqitqa deyin UNION gilit sózi járdeminde birlestirilgen soraw nátijeleri qanday tartipte tekstke shiǵariliwi tuwrali aytpadiq. Birlestirilgen natiyjerdi ORDER BY gilit sózi járdeminde tártiplestiriw múmkin. JoqaridaǵI misaldi tárip nomerlerine qaraǵanda tártiplewin kórip ótemiz.
SELECT a.snum, sname, onum, ’Highest oń, odate FROM Salespeople a. Orders b WHERE a.snum = b.snum AND b.amt = (SELECT MAX (amt) FROM Orders сWHERE c.odate = b.odate)
UNION
SELECT a.snum, sname, onum. ’Lowest oń, odate F ROM Salespeople a. Orders b WHERE a.snum = b.snu AND b.amt = (SELECT MIN (amt) FROM Orders сWHERE c.odate = b.odate)