ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Insert Into has a delayed effect compared to native write?

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

  • Insert Into has a delayed effect compared to native write?

    This will be weird.

    I have a procedure with commit control = *none like below. I'm getting a scenario wherein if I call GetSomething right after I PutSomething, it doesn't pull! I confirm it is in the file. I think on the fly it happens too fast and it's getting from a table a data that is not there yet. Is this a thing with DB2? Is this a case where I should use write and chain(n)?

    Code:
    PutSomething('Value1') ;
    GetSomething('Value1') ; <--- Nothing
    Code:
    Dcl-proc PutSomething ;
    Dcl-pi *n Ind ;
      Anything Char(10) ;
    End-pi ;
      Exec Sql Insert Into SomeTable Values(Anything) ;
      Return '1' ;
    End-proc ;
    Code:
    Dcl-proc GetSomething ;
    Dcl-pi *n Like(Anything) ;
      Anything Char(10) ;
    End-pi ;
      Dcl-s w_Anything Like(Anything) Inz(' ') ;
      Exec Sql Select Anything into :w_Anything from SomeTable where Anything =: Anything ;
      Return Anything ;
    End-proc ;

  • #2
    What's the SQLSTATE after your EXEC SQL commands?

    Comment


    • #3
      Originally posted by jtaylor___ View Post
      What's the SQLSTATE after your EXEC SQL commands?
      I haven't checked. I literally don't check the sqlstate I just assume "there's can't be any possible error" and "if it's not there, it's not there".

      I can probably write something to test this theory with 100k records of repeated insert select all while gathering sql diagnostics

      Comment


      • #4
        I had a similar situation happen a few months back where my inserts weren't showing up for a few seconds. There were no errors and I could SQL to see the data but my selects weren't finding the match. I was in a rush at the time to deliver the project, so I never confirmed what the issue was and just switched to a write which resolved the issue.

        I would be curious to know what could cause this though, or rather, how to prevent it in the future.

        Comment


        • #5
          Maybe you need to return W_Anything instead of Anything.

          Code:
          Exec Sql Select Anything into :w_Anything from SomeTable where Anything =: Anything ;
          Return w_Anything ;
          Maybe you need to assign GetSomething to a variable.

          Code:
          SomeVar = GetSomething ('Value1')
          Maybe I'm not understanding. You have a lot of Anythings in your code.

          Comment


          • OLDMAN25
            OLDMAN25 commented
            Editing a comment
            Yeah sorry I'll have to write something as400 would understand then edit the codes on the post

        • #6
          Shouldn't it be:
          Code:
          Exec Sql Insert Into SomeTable Values([SIZE=20px][COLOR=#FF0000][B]:[/B][/COLOR][/SIZE]Anything) ;

          Comment


          • OLDMAN25
            OLDMAN25 commented
            Editing a comment
            Yeah sorry gonna re-do it with something more readable
        Working...
        X