ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problems with an INSERT with embedded SQL

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

  • Problems with an INSERT with embedded SQL

    Hello dear community,
    I'm currently having trouble with an insert. I can't get an insert. In the debug I saw that the SQLCOD was set to -7008 (object-name NOT VALID FOR
    OPERATION (reason code)). I've attached an image. Can someone tell me what I'm doing wrong? I create the file in QTEMP beforehand. That works too.
    The file has only one field (CHAR length: 11).

    Thank you in advance for your help.


  • #2
    You are trying to execute your INSERT Statement under commitment control and your file is not registered in a journal.
    Make sure you set the compile option COMMIT *NONE. Alternatively you an include an SQL SET OPTION Statement in your RPG source which includes the COMMIT = *NONE option. (a SET OPTION Statement must be physically the first SQL statement in your source.

    Comment


    • user13482104
      user13482104 commented
      Editing a comment
      Many thanks for your response. Forgive me for asking again, but I'm relatively new to the field. What exactly does the statement have to look like? Can you help me again here?

      Thanks very much!

      P.S. Wenn ich richtig sehe und Sie sind Britta Hauser, dann können wir auch gerne auf Deutsch kommunizieren.

  • #3
    I cannot see your attached screenshot for some reason, so I'm not 100% sure.

    There are three ways of disabling commitment control.

    1. You can use an option on the compile command to disable commitment control by default for all SQL in the program
    The command for compiling an SQLRPGLE program is CRTSQLRPGI, and it has option COMMIT, which can be set to *NONE

    2. You can use a Set Option sql statement in your PRGLE program to disable commitment control by default for all SQL in the program
    At the top of your RPG source, below your global variable definitions and before the first subroutine/procedure/executable code line/sql statement, have this line:
    Code:
    exec SQL set option commit = *none;
    3. You can disable commitment control on an individual SQL statement by adding "with nc" to the very end. E.g.:
    Code:
    exec sql insert into qtemp/mytable
      values (1,2,3,'abcde')
      with nc;

    Comment

    Working...
    X