PDA

View Full Version : How to Execute SQL commands from within a CL pgm



K.Forsythe
04-11-2006, 11:44 AM
If the SQL statement never changes, then write it once in a source member and use RUNSQLSTM to execute it. If it needs to accept parameters then write it in QMQRY, or RPG/COBOL with embedded SQL, and pass whatever parms it needs. But...CL has no direct support for SQL without using some sort of add on tool. Did that help? Kevin

Guest.Visitor
04-13-2006, 03:05 AM
Hi, an other way is to use the QSH-Command Birgitta <hr width=50 align=left>Code ('http://www.mcpressonline.com/mc/showcode@@.6b369cf3/1')

Guest.Visitor
04-13-2006, 09:00 AM
Hi Birgitta, I thought the DB2 command in QShell was an undocumented utility for internal IBM developers. In other words, is there any guarantee that it will be supported on future releases of OS/400? If not, I think just passing a parm to an RPG program that does an EXECUTE IMMEDIATE would be a better solution. Regards, Chris

Guest.Visitor
04-17-2006, 07:13 AM
This is great. Thanks so much for all your advice.

MarkusDrossel
04-19-2006, 09:32 AM
Hi, simply try following and use ONLY the sql naming convention: CALL PGM(QZDFMDB2) PARM('DELETE FROM MYLIB.MYTABLE WHERE MYFIELD1 = ANYVALUE') Regards Markus

Guest.Visitor
04-19-2006, 10:16 AM
I need to perform the Delete SQL command. Can this be executed from within a CL pgm or do I need to create a procedure that the CL pgm must call? In short dan you execute SQL interactivly from within a CL pgm?

M.Sansoterra
04-19-2006, 10:16 AM
If you're willing to go to the trouble of loading a utility, here is one that can help: http://www.mcpressonline.com/mc?1@175.koVMfHb6dae.1@.6ae7d3dd!sectionid=.5bfbae a4 The one benefit this utility can offer is the ability to easily retrieve the number of rows affected by an insert, update or delete statement.