Re: Child process does not inherit parent's working library



the standard SQL way is to issue an set current_schema sql statement.
another opportunity is to set the schema with the connect or (in my opinion
worse) to use SQL naming instead of naming(*SQL) at compiletime.

Dieter Bender

Mr. K.V.B.L. wrote:

On Dec 23, 3:14 am, dieter.ben...@xxxxxxxxxxx wrote:
one thing you should have in mind is, that multithreading starts an
additional BCI Job if the referred JOBD of SBMJOB has ALWMLTTHD(*NO), but
this should not change the curlib.
if your socket listener using spawn is written in rpg or uses rpg
programms or serviceprogramm, it would'nt work anyway, because rpgs multi
threading capabilities are very limited (even in V6R1 - compared to c++
or java)

Dieter Bender



Mr. K.V.B.L. wrote:
SBMJOB
CMD(CALL PGM(KBEARD/TRANS_ENG)
PARM('666'))
JOB(TRANS_ENG)
JOBQ(*LIBL/QS36EVOKE)
CURLIB(ICCTEST01P)
CPYENVVAR(*YES)

I have this SBMJOB command.  TRANS_ENG is program that is doing socket
communications.  It receives a message, looks at the message, and
decides which program to start based on the content.  However, the
child programs it starts do not have the current library set to the
parent's (which I have set manually via the CURLIB parameter).  They
are started in my default library instead.  TRANS_ENG uses spawnp() to
start these programs.  The documentation at

http://publib.boulder.ibm.com/iseries/v5r1/ic2924/index.htm?info/apis...



says that the child process inherits the current working *directory*
but no mention is made of the current working library.

So how can I get the child programs to start working in the library I
specify with CURLIB()?



Ok everyone, I think I am sorted out. Turns out my programs do seem
to starting off in the current library of the job that is spawn()-ing
them. I wrote a quick routine that used QWCRTVCA() to fetch the
current library and it was correct. What was throwing me off is the
CLI SQL routines I am using do not default to the current library if
you do not set a library. They use your user profile library. So I
was seeing all of these CLI routines fail because they weren't using
the program's current library but mine.


As a contribution to the group, here is a C++ routine to get the
process' current working library. If you see any problems with it,
let me know.

#include <iostream>
#include <string>
#include <cstdio>
#include <qusec.h>
#include <qwcrtvca.h>
#include <qusrjobi.h>


using namespace std;


const int IBM_Current_Library = 310;
const int IBM_Product_Libraries = 1660;
const int IBM_System_Library_List = 1980;
const int IBM_User_Library_List = 2110;
const int IBM_All_Library_Portions = 2702;


typedef struct {
Qus_EC_t ec_fields;
char Exception_Data[200];
} error_code_t;

typedef _Packed struct {
Qwc_RTVC0200_t rtvc0200;
char arrayOfLibs[1000];
} RTVC0200;



/*
Module:
GetCurLib()
Synopsis:
Get current library from the AS/400
Returns:
Nothing (void).
Written by:
Kelly Beard
Compilation:
CRTBNDCPP PGM(LIB) SRCSTMF(LIBRARY.CPP) DEFINE(TEST_MAIN)
*/
void GetCurLib(string& currentLibrary)
{
static int attribKeys[1];
static error_code_t error_code;
static first_time = true;
RTVC0200 currentLibList;
size_t found;


if (first_time) {
first_time = false;
error_code.ec_fields.Bytes_Provided = sizeof(error_code_t);
attribKeys[0] =
IBM_Current_Library;
}

QWCRTVCA(&currentLibList, sizeof(currentLibList), "RTVC0200", 1,
&attribKeys[0], &error_code);
if (error_code.ec_fields.Bytes_Available == 0)
{
currentLibrary.assign(currentLibList.arrayOfLibs, 10);
found = currentLibrary.find(' ');
if (found != string::npos) {
currentLibrary.erase(found);
}
}
}


#if defined(TEST_MAIN)
int main(int argc, char *argv[])
{
string str;

GetCurLib(str);

cout << "{" << str << "}" << endl;
}
#endif

.



Relevant Pages

  • Re: Serious errors with Create view command
    ... subdepts, groups of subdepts make depts anmd groups of depts make Divisions ... Using VFP9 your CREATE VIEW displays like this in the View Designer View SQL ... and the routine simply fails to perform properly. ...
    (microsoft.public.fox.helpwanted)
  • Re: Programming for all fields in a table
    ... then that "main" routine would branch out to other ... Most code now runs in RESPONSE to a event. ... While a array was likely the most important data type in FORTRAN, ... tables as we got a "sql" engine to do the work for us. ...
    (comp.databases.ms-access)
  • Re: TIP#308: Last serial column value generated
    ... Where did I say that SQL doesn't return ordered fields? ... I eliminated changing a routine used in a number of places, and simply made use of extra data, which wouldn't have worked had I not used *. ... in queries where the column is a function. ... I didn't dispute that. ...
    (comp.lang.tcl)
  • Re: Informix beats Oracle
    ... SQL and PL/SQL" ... There should a means to use "invoker"s rights which basically turns a routine into a macro. ... Anyway there are countless differences between Oracle SQL and PL/SQL in packages. ...
    (comp.databases.informix)
  • Re: i-Series Navigator SQL procedure inserts to existing records
    ... programs and procedures via CL and RPG, ... recently started creating SQL procedures through i-Series Navigator, ... Production supervisor inquires to ...
    (comp.sys.ibm.as400.misc)

Loading