ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SQL error

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

  • SQL error

    Hi

    I am trying to insert a record by embedded SQL in an SQLRPGLE source. I am getting error "SQLCOD = -000007008".

    Can someone please help why i am not able to insert the record?

  • #2
    Re: SQL error

    MSGID SQL7008 in QSQLMSG message file shows " &1 in &2 not valid for operation. "

    Check the joblog.
    Philippe

    Comment


    • #3
      Re: SQL error

      here is a nice site for for SQL messages

      To every equation there is a solution....
      Regards
      Sai.

      Comment


      • #4
        Re: SQL error

        Hi,

        SQLCODE -7008 means that you try to do an insert, update or a delete on a file/table that is not journaled.

        Here are some solutions for your problem:
        1. Change the compile option Commit in the compile Command CRTSQLRPGI to *NONE
        2. Instead of changeing the compile command, you can insert an SET OPTION Statement with Commit *NONE into your source. The SET OPTION Statement must preceed all other SQL statements in your source.
        C/EXEC SQL Set Option Commit = *NONE
        C/END-EXEC
        3. Specify "With NC" at the end of your Insert, Update or Delete-Statement to execute this statement without commitment control:
        C/Exec SQL Update ...
        C+ With NC
        C/End-Exec
        4. The best/savest way is to register your file in an journal and use commitent control.

        Birgitta

        Comment


        • #5
          Re: SQL error

          HI
          please somebody put here an example of INSERT in sqlrpgle.
          I want to check syntax of command. ( for both state: 1-giving value directly 2-giving a record format structure)

          Yhank you

          Comment


          • #6
            Re: SQL error

            SQL is SQL this is a great site to learn from:

            W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


            Code:
            INSERT INTO table_name
            VALUES (value1, value2,....)
            Code:
            INSERT INTO table_name (column1, column2,...)
            VALUES (value1, value2,....)
            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


            • #7
              Re: SQL error

              And...
              PHP Code:
              INSERT INTO table1 
              (Select column1column2, ... from table2
              Also
              PHP Code:
              INSERT INTO table1 
              (Select from table2
              This last one if table2 columns are compatible with the colums of table1.
              Philippe

              Comment


              • #8
                Re: SQL error

                Thank you Mercury and JAmief,

                But i have values in variables of a data strusture, how could use that data structure in INSERT command. I mean I don't want to give values directly in INSERT command; because the InSERT command is in a loop and in the first of loop the values feeds to variables and then an INSERT command inserta that to table.

                Thank you

                Comment


                • #9
                  Re: SQL error

                  Hi,

                  just try:

                  PHP Code:
                  Insert into MySchema/MyTable
                    x Rows Values
                  (:Host-Structure-Array); 
                  Where x is the number of rows to be inserted.

                  Birgitta

                  Comment

                  Working...
                  X