ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Error state persists

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error state persists

    I'm trying to make an update on a table which fails (as it should because of constraints). This causes an sql error.

    I then try to select all rows in a table using a declare. When I check the state it says there is an sql error.
    The error however is from the attempted update (I know this as it completes correctly when the update does not fail).
    Code:
                  Exec SQL Declare HyppighedListe cursor for
                           select id, tekst from FilOprHyp
                           order by id;
    Is there some way to 'zero out' the sql error?

    Note:
    I'm finding the sql code with:
    Code:
            EXEC SQL Get Diagnostics Condition 1                                                        
                         :Resultat = DB2_RETURNED_SQLCODE; // Workaround for incorrect SQLCA             
                                                                                                        
            return Resultat;
    As I have service program with some helpful sql functions which would otherwise not be able to get the correct sql code.

    I hope someone out there knows a way around this problem...
    ~Alice
    http://dk.linkedin.com/in/aliceraunsbaek

  • #2
    Re: Error state persists

    A Declare Statement will not cause an error, i.e. will not replace the current SQL Code.
    You need to check the SQL code after the open statement.

    Birgitta

    Comment


    • #3
      Re: Error state persists

      You say you are doing an update which fails. You do not say if this is an SQL update or an RPG update. If it is an RPG update, try unlocking the record after the fail.
      Regards

      Kit
      http://www.ecofitonline.com
      DeskfIT - ChangefIT - XrefIT
      ___________________________________
      There are only 3 kinds of people -
      Those that can count and those that can't.

      Comment


      • #4
        Re: Error state persists

        Originally posted by kitvb1 View Post
        You say you are doing an update which fails. You do not say if this is an SQL update or an RPG update. If it is an RPG update, try unlocking the record after the fail.
        It's a SQL update.
        http://dk.linkedin.com/in/aliceraunsbaek

        Comment


        • #5
          Re: Error state persists

          Originally posted by B.Hauser View Post
          A Declare Statement will not cause an error, i.e. will not replace the current SQL Code.
          You need to check the SQL code after the open statement.
          So my extensive error checking finally got the better of me... *sigh*

          Once I removed the check for error between the declare and open statements the problem went away.

          Thank you =0)
          http://dk.linkedin.com/in/aliceraunsbaek

          Comment

          Working...
          X