ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SQLRPGLE Compile error

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

  • SQLRPGLE Compile error

    Hi All,

    Need help again

    I am facing a compile time error while compiling this sqlrpgle program....

    Code:
    MSG ID  SEV  RECORD  TEXT                                               
    SQL5066   0    3371  Precompile option CLOSQLCSR changed by SET OPTION  
                         statement.                                         
    SQL0084  30    3372  Position 9 SQL statement not allowed.
    here is the line;
    Code:
    3372        C+ SET OPTION CLOSQLCSR = *ENDMOD
    while I remove/comment this line and compile everything goes fine. I know that I can specify this option while compiling the program, but this was how the program was initially....so I was wondering why this error came up.

    Actually, this program was not compiled with source/ so I thought of compiling it again in my usrlib to debug but received this error instead

    any comments are welcome....

  • #2
    Re: SQLRPGLE Compile error

    This works for me

    Code:
    exec sql  set option commit=*none,datfmt=*iso, 
                  closqlcsr=*ENDMOD;

    Code:
    c/Exec SQL                                    
    c+  set option  closqlcsr=*ENDMOD             
    c/end-exec                                    
                                                  
    c                   eval      *inlr = *on
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: SQLRPGLE Compile error

      what do lines 3371 and 3373 look like?
      "Time passes, but sometimes it beats the <crap> out of you as it goes."

      Comment


      • #4
        Re: SQLRPGLE Compile error

        here it is...

        Code:
        3370.00  * Set Compile Option                  
        3371.00 C/EXEC SQL                        
        3372.00 C+ SET OPTION CLOSQLCSR = *ENDMOD 
        3373.00 C/END-EXEC

        Comment


        • #5
          Re: SQLRPGLE Compile error

          isnt that what I wrote?
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: SQLRPGLE Compile error

            Hi,

            First a few questions:
            On which release are you working?
            On release V5R4?
            If so are there any other SQL statements in your souce code that preceede the SET OPTION statement?

            Beginning with release V5R4 the SET OPTION statement must be the first SQL statement in your source code.

            Are there more than one SET OPTION Statement in your source code?

            SET OPTION statements are Highlanders, i.e. only a single SET OPTION statement is allowed in a source. Before release V5R4 the number of SET OPTION statements was not checked, but only the first one considered and the other ones were ignored.

            SET OPTION statements are compile options (the H-Specs for SQL-Statements) and in this way they can only be specified once and must preceed all other SQL statements.

            BTW please do not change CLOSQLCSR to *ENDMOD. When *ENDMOD is specified, the SQL cursors are hard closed at the end of the module. That means all ODPs will be deleted. Next time you call the module in your job a full optimization must be performed, which is the most time expensive part of executing a SQL statement.

            Birgitta

            Comment


            • #7
              Re: SQLRPGLE Compile error

              Birgitta,
              Thanks for the reply. We are working on V5R4. The program is an SQLRPGLE. and this code is present in the INZSR subroutine.

              Execution wise this is the first line of sql code that is being executed, but there are other lines present as well.

              I tried to move these lines to the beginning of the INZSR, but even then it didn't work.

              My program has more of RPG than SQL......

              Comment


              • #8
                Re: SQLRPGLE Compile error

                forgot to mention one more thing; there aren't any more SET OPTION commands as well...

                any thoughts....

                Comment


                • #9
                  Re: SQLRPGLE Compile error

                  Not at the beginnin of the *INZSR it must be the first SQL statement in your source code.

                  The precompiler which fails does not know anything about the sequence in which your source code will be executed, nor doest it know anything about the *INZSR, that means it only scans your source code for SQL statements, checks them, comments them out and replaces them through API calls.

                  A Set option statement is never executed, it only contains compile options. That's why it must be the first SQL statement in your source code.

                  In my embedded SQL programs the SET OPTION-Statement is always the first statement immediately after the D-Specs.

                  Birgitta

                  Comment


                  • #10
                    Re: SQLRPGLE Compile error

                    Birgitta,
                    you mentioned that SET OPTION statements can only be specified as compile options, can you tell me how that can be done. thx

                    Comment


                    • #11
                      Re: SQLRPGLE Compile error

                      Originally posted by B.Hauser View Post
                      Not at the beginnin of the *INZSR it must be the first SQL statement in your source code.
                      Birgitta
                      thx a lot it worked.

                      Comment

                      Working...
                      X