PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Join the forum, it's quick and easy

PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).
PMS Information Systems
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Can I pass parameters to an SQL statement in a source member before executing the Run SQL Statement (RUNSQLSTM) command?

Go down

Can I pass parameters to an SQL statement in a source member before executing the Run SQL Statement (RUNSQLSTM) command? Empty Can I pass parameters to an SQL statement in a source member before executing the Run SQL Statement (RUNSQLSTM) command?

Post  maran Fri Dec 30, 2011 11:35 am

Yes. This can be achieved using QSHELL.

See the Code below:

CLLE Code:

PGM PARM(&DEPT)

DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE('MARAN')
DCL VAR(&FILE) TYPE(*CHAR) LEN(10) VALUE('QSQLSTMSRC')
DCL VAR(&PATTERNMBR) TYPE(*CHAR) LEN(10) +
VALUE('UPDDEP')
DCL VAR(&SQLCMDMBR) TYPE(*CHAR) LEN(10) +
VALUE('UPDDEP1')
DCL VAR(&DEPT) TYPE(*CHAR) LEN(2)
DCL VAR(&SHELLCMD) TYPE(*CHAR) LEN(256)

CHGVAR VAR(&SHELLCMD) VALUE('sed "s%CC%' *CAT +
&DEPT *CAT '%g"' *BCAT '/qsys.lib/' +
*CAT &LIB *TCAT '.lib/' *CAT &FILE *TCAT +
'.file/' *CAT &PATTERNMBR *TCAT '.mbr' +
*BCAT '>/qsys.lib/' *CAT &LIB *TCAT +
'.lib/' *CAT &FILE *TCAT '.file/' *CAT +
&SQLCMDMBR *TCAT '.mbr')
QSH CMD(&SHELLCMD)
RUNSQLSTM SRCFILE(&LIB/&FILE) SRCMBR(&SQLCMDMBR) +
COMMIT(*NONE)
ENDPGM
_____________________________________________

SQL Statement:

update EMPMST
set EMPAD1 = 'CHENNAI'
where EMPDEP = 'CC'
_________________________________________________
maran
maran
Admin

Posts : 442
Join date : 2009-07-24

https://pmsinformationsystem.forumotion.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum