![]() | |
#1
| |||
| |||
|
|
Hi! I have an SQL script with bunch of CREATE TABLES, ALTER TABLES, ... I'd like it to run transactially. I have found that id I run a ALTER STATEMENT inside a transaction and then roll it back the changes disapear. So if this works for one statement it should also for a script, right ? I run the script with the following command: db2cmd -c -w -i db2 -t -f SCRIPT.SQL In this SCRIPT.SQL the connection to the database is made (CONNECT TO DB USER ....). What do I have to do to run this inside a transaction? Best regards, Kovi |
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
#8
| |||
| |||
|
|
OK. I agree. This is going to work if you run it from shell, but how if you try to run it from a Java program for example. There do you a: String command = "cmd /c db2cmd -c -w -i db2 +c -td# -f SCRIPT.SQL"; Process proc = Runtime.getRuntime().exec(command); int errorCode = proc.waitFor(); I can see that something was wrong or not (by the value in errorCode). How do I do a commit or rollback ? |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
Hi! Thanks for all your help. I also susspect I'd have to do something in the line of Option 2, but that was not very attractive to me. I thought that someone knows a secret. ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |