|
Hi Allan,<snip>I do that little trick to avoid having to hardcode the library
into the
script. When you compile the object, the AS/400 comes up with a library
to stick it in. How I do not know so the trick was to create the object
and move to where I wanted it to be. If you put a library into default
collection, it then wants to find the files in the default collection
instead of on the library list. So I let it compile where it wants and
then move.
</snip>I solved the problem of hardcoding the current schema by creating a
temporary source file.
In member AAA there's one record that defines what the current schema is:
SET CURRENT SCHEMA MYDESTLIB
In member BBB are the rest of the create statements located.
I have a build CL to concat these two members and execute the RUNSQLSTM.
Below is a simplified example. Most times I define extra parameters for the CL
call
in which I can define what sourcemembers to take.
Best regards,
Arco Simonse
PGM
/* Check for temp files to delete first */
DLTF FILE(QTEMP/TEMPSRCF) MONMSG
MSGID(CPF2105)
/* Create temp source file */ CRTPF
FILE(QTEMP/TEMPSRCF) RCDLEN(112) + FILETYPE(*SRC)
MBR(TEMPMBR)
/* Copy the source with current schema setting */ CPYSRCF
FROMFILE(MYSRCLIB/DBSRC) + TOFILE(QTEMP/TEMPSRCF)
FROMMBR(AAA) + TOMBR(TEMPMBR) MBROPT(*ADD)
/* Bring in the source with sql build statements */ CPYSRCF
FROMFILE(MYSRCLIB/DBSRC) + TOFILE(QTEMP/TEMPSRCF)
FROMMBR(BBB) + TOMBR(TEMPMBR) MBROPT(*ADD)
/* Execute the temp source
*/ RUNSQLSTM SRCFILE(QTEMP/TEMPSRCF) SRCMBR(TEMPMBR)
+ NAMING(*SQL) ERRLVL(20) DFTRDBCOL(*NONE) +
CLOSQLCSR(*ENDMOD)
/* Cleanup qtemp */ DLTF
FILE(QTEMP/TEMPSRCF)
ENDPGM
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.