Hi,
I am using the following if statment in my sql code. The problem i have is that the update statment runs successfully irregardless of wether my insert statment is successfull or not. What I need to do is if the insert is successfull run the update statement and if the insert fails at any point the update statment should fail.
The SQL statment is as follows:
IF EXISTS (select from table1statment stating the condition to excute the insert statment)
INSERT INTO table1(a,b)
select (a,b) from table2
UPDATE table1
SET flag = 'DONE' WHERE condition.
Thanks.
I am using the following if statment in my sql code. The problem i have is that the update statment runs successfully irregardless of wether my insert statment is successfull or not. What I need to do is if the insert is successfull run the update statement and if the insert fails at any point the update statment should fail.
The SQL statment is as follows:
IF EXISTS (select from table1statment stating the condition to excute the insert statment)
INSERT INTO table1(a,b)
select (a,b) from table2
UPDATE table1
SET flag = 'DONE' WHERE condition.
Thanks.
Comment