Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
whitepear
Starting Member
24 Posts |
Posted - 2014-04-19 : 03:50:47
|
Hello!Please, this is hte first transaction I made in my life, and I am not sure I understand what is actually happening there.I actually do not understand the line :when others thenothers stands for a certain condition, which is in this case "general".Please, could someone explain me clearly what is happening in this line.BEGIN TRANSACTION;DROP TABLE IF EXISTS PUPIL;CREATE TABLE PUPIL(PN INTEGER PRIMARY KEY,PNAME TEXT);COMMIT;BEGIN TRANSACTION;INSERT INTO PUPIL VALUES(1,'AAA');INSERT INTO PUPIL VALUES(2,'BBB');INSERT INTO PUPIL VALUES(3,'CCC');INSERT INTO PUPIL VALUES(4,'DDD');COMMIT;SELECT * FROM PUPIL;BEGIN;SAVEPOINT SPX;INSERT INTO PUPIL VALUES(5,'EEE');INSERT INTO PUPIL VALUES(6,'FFF');COMMIT;BEGIN TRANSACTION;EXCEPTIONWHEN OTHERS THENROLLBACK TO SPX raise_application_error(-20100, SQLRRM);END; SELECT * FROM PUPIL;P.S. eXECUTION IS:1|AAA2|BBB3|CCC4|DDDError: near line 28: near "EXCEPTION": syntax error1|AAA2|BBB3|CCC4|DDD5|EEE6|FFFhOW DO i GET RID OF THE MISTAKE IN LINE 27?mANY THANKS!!!I just know, when condition = others, in that case rollback will undo insert in in 5th and 6th row of the table.So, what is "others" meaning acutally?Manny thanks and sorry for confusion!!! |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-04-19 : 07:19:33
|
are you using Microsoft SQL Server ? If not, try posting at other forum KH[spoiler]Time is always against us[/spoiler] |
|
|
whitepear
Starting Member
24 Posts |
Posted - 2014-04-19 : 11:05:50
|
is is www.compileonline.com/online compiler , also for sqlWhich forum do u reccomad?Many thanks! |
|
|
|
|
|
|
|