Hi all,
I've a service program that contains some procedures that delete, insert or update records of several files using embedded SQL.
Unfortunately, when I created the service program years ago I followed the principle "when using SQL always set option commit = *none".
Now I want to switch to commitment control in new programs that are calling procedures of the service program without having to change the existing calling programs.
What I have done so far:
In each procedure I would write
at the appropriate positions in my code.
Doing so -- my hope is -- I won’t have to recompile all programs that use the service program.
A new calling program would call the service program procedures with CommitToBePerformed set to *off like this:
Do you think this is generally a good idea?
Or is there a better practice?
Thanks
I've a service program that contains some procedures that delete, insert or update records of several files using embedded SQL.
Unfortunately, when I created the service program years ago I followed the principle "when using SQL always set option commit = *none".
Now I want to switch to commitment control in new programs that are calling procedures of the service program without having to change the existing calling programs.
What I have done so far:
- First step was to set actgrp(*caller) in the service program.
- Second to eliminate "exec sql set option commit = *none".
- The third step was to add a parameter "CommitToBePerformed ind options(*nopass)" to all procedures setting its default to *on.
In each procedure I would write
Code:
if CommitToBePerformed; exec sql commit; else; // do nothing - caller decides if to commit or rollback endif;
Doing so -- my hope is -- I won’t have to recompile all programs that use the service program.
A new calling program would call the service program procedures with CommitToBePerformed set to *off like this:
Code:
id1 = srvP1WriteFile1('name':'age':*off); // *off => no commit performed by procedure id2 = srvP1WriteFile2(id1:'age':*off); // *off => no commit performed by procedure if id2 > 0; exec sql commit; else; exec sql rollback; endif;
Or is there a better practice?
Thanks
Comment