Reputation: 362
I am searching for an option to operate with transactions in the IBM SQL-Scripts program. For comparison purposes, i added an image on what SQL-Scripts-Program i am talking about.
Further, I also want to achieve those transactions programmatically with RPG(free). How could this look like?
Upvotes: 0
Views: 1482
Reputation: 23823
You mention both the Run SQL Scripts utility, and RPG.
You've got basically two choices in either place.
with
clause to individual statements to override the default.For Run SQL Scripts, the default is configured in the JDBC connection.
For SQLRPGLE, the default can be set
COMMIT()
parameter of the CRTSQLRPGI
commandSET OPION
SQL statement in your sourceSET OPTION
is preferred, unless you have a CMS that can ensure the CRTSQLRPGI command is always issued properly.
exec SQL
set option commit = *CHG;
Note that the SET OPTION
statement is a compile time, not run-time statement. It must be the physically first SQL statement in your SQLRPGLE module. You can only have one and it is in effect for the entire module.
Regardless of the default isolation/commitment level in effect. You can set the level for a given statement using the WITH
clause.
update mytable
set mycolumn = 1
with chg;
Lastly, note that in order to use commitment control, your table will have to be journaled.
Upvotes: 2
Reputation: 3901
See the compound (dynamic) statement
Note that you will need to use a statement terminator other than ;
in your SQL Editor. @
is a commonly used one.
Also if you use IBM Data Studio you will get local syntax parsing which will help you spot any syntax errors in your code.
Upvotes: 1