Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setSqlServerMode as a utility procedure #105

Open
m1h43l opened this issue Jun 13, 2021 · 2 comments
Open

Add setSqlServerMode as a utility procedure #105

m1h43l opened this issue Jun 13, 2021 · 2 comments

Comments

@m1h43l
Copy link
Collaborator

m1h43l commented Jun 13, 2021

When a web service uses SQL transactions it needs to scope these to the thread and not the job or activation group. The could be done with the Change Job API. It would be great if we could add that to the ILEastic API.

The RPG code may look like this:

dcl-proc il_setSqlServerMode;
  dcl-pr sys_changeJob extpgm('QWTCHGJB');
    job char(26) const;
    internalJobId char(16) const;
    format char(8) const;
    jobChangeInfo char(1000) const options(*varsize);
    errorCode likeds(qusec);
  end-pr;

  dcl-ds jobc0200 qualified template;
    numberKeys int(10) inz(1);
    fieldInfoLength int(10) inz(20);
    keyField int(10) inz(1922);
    dataType char(1) inz('C');
    reserved2 char(3);
    lengthData int(10) inz(1);
    data char(1) inz('1');
    reserved3 char(3);
  end-ds;


  dcl-ds error likeds(qusec) inz;
  dcl-ds jobData likeds(jobc0200) inz(*likeds);

  sys_changeJob('*' : '' : 'JOBC0200' : jobData : error);
end-proc;
@MarkBoyer
Copy link

@m1h43l I'm not very familiar with thread safety in RPG. Does this change need to take place in each procedure that uses SQL or in the main "driver" procedure only? In our implementation, we have a main program that sets up the config object, adds routes and then call il_listen. We have a series of procedures group edinto service programs by category (security, purchasing, etc.). TIA

@m1h43l
Copy link
Collaborator Author

m1h43l commented Oct 28, 2022

@MarkBoyer It just needs to be executed once at the beginning of the program before any SQL is executed. So the main procedure is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants