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

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

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

View previous topic View next topic Go down

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

Post  maran on 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
Admin

Posts : 442
Join date : 2009-07-24

View user profile http://pmsinformationsystem.forumotion.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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