ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Which row caused insert statement to fail?

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

  • Which row caused insert statement to fail?

    If I do an insert into a table with a select from another table and it fails, is there a way to determine which row caused it to fail? Is there a way in embedded sql?

  • #2
    Originally posted by jayvaughn View Post
    If I do an insert into a table with a select from another table and it fails, is there a way to determine which row caused it to fail? Is there a way in embedded sql?
    GET DIAGNOSTICS includes last row and row count. I would think they should be updated at the failure point. There may be other useful values there too.

    Comment


    • #3
      That crossed my mind and I hope it works when I get a chance to try. Any other possibilities? Thx John boy

      Comment


      • #4
        What was the failure? I.e., what error, SQL state/code, was returned? If you have a SELECT and the INSERT file is available, you should be able to run the SELECT with some join (or EXISTS() or whatever) to see intersections that interfere. And if it's a data mapping error, other simple tests are possible.
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment

        Working...
        X