Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

How to Execute SQL commands from within a CL pgm

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to Execute SQL commands from within a CL pgm

    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

  • #2
    How to Execute SQL commands from within a CL pgm

    Hi, an other way is to use the QSH-Command Birgitta
    Code

    Comment


    • #3
      How to Execute SQL commands from within a CL pgm

      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

      Comment


      • #4
        How to Execute SQL commands from within a CL pgm

        This is great. Thanks so much for all your advice.

        Comment


        • #5
          How to Execute SQL commands from within a CL pgm

          Hi, simply try following and use ONLY the sql naming convention: CALL PGM(QZDFMDB2) PARM('DELETE FROM MYLIB.MYTABLE WHERE MYFIELD1 = ANYVALUE') Regards Markus

          Comment


          • #6
            How to Execute SQL commands from within a CL pgm

            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?

            Comment


            • #7
              How to Execute SQL commands from within a CL pgm

              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@17...onid=.5bfbaea4 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.

              Comment

              Working...
              X