Inhoud blog
  • Original CL vs. ILE CL
  • Windows and Other Functions in iSeries Access PC5250
  • XML, Namespaces, and Expat
  • Quick Download of All Source Members to a PC
  • Retrieve Source Code of ILE CL
    Zoeken in blog

    Qmma developer network

    14-12-2006
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.Executing SQL Statements from CL Programs

    Q: Is it possible to execute SQL statements from within a CL program?

    A: Yes, you can run SQL statements from a CL program. To do so, you place your SQL statements in a source file member and then use command RunSQLStm (Run SQL Statements) to execute the statements in the member.

    For example, suppose you wish to set field ProcFlag to value Y in all records found in file YourLib/YourFile. The following SQL statement accomplishes this:

    Update YourLib/YourFile
      Set ProcFlag = 'Y'

    Simply create a source member with the above SQL statement and then in your CL program issue the following command:

      RunSQLStm  SrcFile( YourLib/YourSrcF ) SrcMbr( YourMbr )

    14-12-2006 om 10:34 geschreven door Qmma  


    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.Running SQL in Batch

    You can run SQL statements in a batch job by submitting the RunSqlStm (Run SQL Statements) command. This command executes SQL statements stored in a source member. The source member can contain any valid SQL statements. Each SQL statement in the member must be separated by a semicolon.

    Here's a simple example. Source member MySQL in file MySrc updates all the records in file InvMst and deletes selected records from file InvBal:

    Update  InvMst 
     set    ImCls = 'AA', 
            ImTyp = '1'; 
    Delete  from InvBal 
     where  IbQtyStk = 0;

    To execute these SQL statements in batch with no commitment control, you would specify the following RunSqlStm command in the Cmd parameter of the SbmJob (Submit Job) command:

    RunSqlStm SrcFile( *Libl/MySrc )           + 
              SrcMbr( MySrc )                  + 
              Commit( *None )

    14-12-2006 om 10:33 geschreven door Qmma  




    Archief per maand
  • 04-2007
  • 03-2007
  • 02-2007
  • 01-2007
  • 12-2006
  • 11-2006
  • 10-2006
  • 08-2006
  • 07-2006
  • 09-2005

    E-mail mij

    Druk op onderstaande knop om mij te e-mailen.



    Blog tegen de wet? Klik hier.
    Gratis blog op https://www.bloggen.be - Meer blogs