Sameer Ranalkar
Sameer Ranalkar

Reputation: 1

how to write on error rollback in IBM DB2 WinSQL sql script

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.

Upvotes: 0

Views: 242

Answers (1)

user3523268
user3523268

Reputation: 101

Try enclosing the statements between a BEGIN and END

Upvotes: 0

Related Questions