0

Example :

Let's say, I have 3 INSERT statements. I am using WinSQL to execute the following script:

SAVEPOINT A;

INSERT_STATEMENT 1;

INSERT_STATEMENT 2;

INSERT_STATEMENT 3;

Now, INSERT_STATEMENT 1 is successful.

INSERT_STATEMENT 2 is successful.

INSERT_STATEMENT 3 has got into error, so I want to rollback to SAVEPOINT A;

How can we do that?

Please note: We are allowed to run a SQL script in the production through mainframe, so not sure if writing a function(with condition codes) for this will work because functions work when a language like JAVA is involved. My point is to write script directly into winSQL without any external programming language. Could you please guide me.

Thank you.

It_is_Chris
  • 13,504
  • 2
  • 23
  • 41

1 Answers1

0

Try enclosing the statements between a BEGIN and END

user3523268
  • 101
  • 1
  • 2
  • 6
  • I tried using the following script : BEGIN WORK; LOCK TABLE TABLE_NAME INSERT_STATEMENT; UPDATE_STATEMENT; COMMIT WORK; But getting an error : Error: SQL0199N The use of the reserved word "WORK" following "" is not valid. Expected tokens may include: "DECLARE". SQLSTATE=42601. Not sure if BEGIN-END works in DB2. Any idea about how we can write script. Thank you – Sameer Ranalkar Dec 26 '18 at 07:09