SQL RPG and the annoying compile COMMIT *NONE thing

  • Home
  • /
  • Blog
  • /
  • SQL RPG and the annoying compile COMMIT *NONE thing

November 12, 2013

SQLRPGLE and COMMIT(*NONE)

Moving to SQL (from native file IO) has been a major game changer in the RPG programming world.

SQLRPGLE can be confusing to learn, horrible to use if it needs lots of compile time parameters but using Exec SQL SET OPTION something answers my prayers.

I first played with SQL back the golden days of RPG3 and RPG400 when we were all wrapped up in using Commitment Control. Journaling files and making changes to data in our RPGSQL programs before issuing a COMMIT or ROLLBACK was exciting and new.

Roll forward a few years and database access times have massively increased and the entire concept of commitment control is not something we focus on so much in the RPG programming world.

Because of this history, in modern SQLRPGLE programs, we still have to tell the program not to use commitment if we don’t want to use it. This also means you can use embedded SQL in RPG programs without journaling your files.

COMPILE TIME PARAMETER

The easiest way is to enter the create parameter of COMMIT(*NONE) thing so it turns it off after the first commit without the isolation level nonsense.

SQLRPGLE SET OPTION

USE RPG CODE

This is my preferred technique. Adding a line of code to the program and then know that you never need to specify additional compilation parameters makes me sleep easy at night. Just specify COMMIT *NONE in the compile command or add a SET OPTION statement at the beginning of the program:

RPG3/400

C/EXEC SQL SET OPTION COMMIT = *NONE
C/END-EXEC

SQLRPGLE:

Exec SQL SET OPTION COMMIT = *NONE;

Easy Peasy, Lemon Squeezy.

Now we can get quite fancy with SQL SET OPTION and use something like this:

EXEC SQL
Set Option
Naming = *Sys,
Commit = *None,
UsrPrf = *Owner,
DynUsrPrf = *Owner,
CloSqlCsr = *EndMod;

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits.

Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day.

Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

  • My create table was in a subroutine. Adding the commit=*none wouldn’t allow a compile. I finally found your website where the *none belongs at the beginning of the program. Worked like a charm. Thanks for your help!

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Subscribe NOW
    7-day free trial

    Take This Course with ALL ACCESS

    Unlock your Learning Potential with instant access to every course and all new courses as they are released.
     [ For Serious Software Developers only ]

    Online Learning for IBM i Software Technology Professionals

    “The more that you read, the more things you will know. The more that you learn, the more places you’ll go.” – Dr. Seuss

    >