ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to execute SQL scripts in source file with SQLRPGLE?

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

  • How to execute SQL scripts in source file with SQLRPGLE?

    I have a set of SQL scripts stored in QSQLSRC. As far as I know I can execute those scripts using RUNSQSTM. But I need to monitor the count as well. So I would like to copy it and execute it from my RPG program like embedded sql and monitor the count. Is there a way I can do this? Or is it possible to get the count from RUNSQSTM? Any help would be appreciated.

  • #2
    RUNSQLSTM outputs results to a spool file. I've done this in the past by using CPYSPLF to copy the resulting spool file to a table, and then parsing it in SQLRPGLE.

    Comment


    • #3
      Vectorspace I have INSERT query in the script and with RUNSQLSTM I execute it. If I use CPYSPLF command and bring the SQL string into RPGLE, and execute again, it will cause duplication right?

      Comment


      • #4
        After executing the insert could you do a

        exec sql GET DIAGNOSTICS :nbrRec = ROW_COUNT;

        to retrieve the number of records inserted?

        Comment


        • #5
          Peder Udesen the insert query is not embedded in RPG, but it is a script saved in source physical file as a member.

          Comment


          • #6
            @nishar I expected that the SQL statement was read from the file the prepared and executed in RPG

            Comment


            • #7
              See my reply in your other thread. I meant for you to extract the results of the SQL from the spool file, not the statement itself.

              Comment

              Working...
              X