ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

CRTSQLRPGI option (*SQL)

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

  • CRTSQLRPGI option (*SQL)


    Hello,

    I have lots of SQLRPGLE programs that I have to compile with OPTION(*SQL).
    99% of the time I forget to set that value at compilation time, so I tried to add this parameter value inside H SPECS.
    Unfortunately it doesn't seem to be any option to set that value in order to properly compile the source code without setting it manually every time.
    Any help is really appreciated ,
    Giovanni

  • #2
    SQL-Precompile Options can be set by adding a SET OPTION Statement to the RPG Code.
    You can only add a single SET OPTION statement (but specifiying multiple options are allowed.
    The SET OPTION statement is not executed only used by the SQL-Precompiler. Since the SQL Precompiler scans the RPG Source, the SET OPTION Statement must be physically the first SQL-Statement in your source code.
    Example:
    Code:
    Exec SQL Set Option DatFmt = *ISO, Naming=*SYS;
    Set Option Statement:
    https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/db2/rbafzsoption.htm

    Birgitta

    Comment


    • #3
      Hello Birgitta,
      it worked !
      Thank you
      Giovanni

      Comment


      • #4
        Originally posted by B.Hauser View Post
        You can only add a single SET OPTION statement (but specifiying multiple options are allowed.
        I assume you mean you can't use a second set option statement change an option mid way through the program, because it's a compile-time option, not a runtime option?

        Because I've used separate set option statements for different values in the past and it has seemed to work:
        Code:
        Exec SQL Set Option DatFmt = *ISO;
        Exec SQL Set Option Naming=*SYS;

        Comment


        • #5
          It could be that the 2nd SET OPTION statement is (today) considered, because you different options are specified.
          But there was a time when only the first one was considered and all other ones were ignored (without compile error!).
          I did not find anything in the documentation, that explicitly forbids a 2nd (or more) SET OPTION statement in embedded SQL.
          But I nowhere saw the term "the SET OPTION Statements" or "a SET OPTION Statement", but always "the SET OPTION Statement".

          ... and for example in SQL PSM (Programming Language) you can only specify a single SET OPTION statement before the Routine Body.

          In either way you should only code a single SET OPTION statement.

          Comment

          Working...
          X