IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

If SQL code + 100 will it execute both the conditions shown


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Fri May 30, 2008 2:37 pm
Reply with quote

Hi,

I have a doubt if SQL code + 100 will it execute both the conditions shown below after 'if SQL code=100' and 'if SQL code not =0', please see the below condition,


IF SQLCODE = +0
DISPLAY 'NUMBER OF ROWS DELETED' SQLERRD(3)
DISPLAY 'SQLCODE = ' SQLCODE
DISPLAY '*** DELETE SUCCESSFUL ***'
ELSE
IF SQLCODE = +100
DISPLAY 'SQLCODE = ' SQLCODE
DISPLAY '*** NO ROWS TO DELETE ***'
GO TO 1000-EXIT
ELSE
IF SQLCODE NOT = +0
DISPLAY 'SQLCODE = ' SQLCODE
DISPLAY '*** DELETE FAILED ***'
MOVE 4 TO RETURN-CODE
GO TO 1000-EXIT
END-IF
END-IF
END-IF.

1000-EXIT.
EXIT.


Thanks,
Kumar.
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Fri May 30, 2008 3:02 pm
Reply with quote

No it will NOT look at below description :

Code:

 IF SQLCODE = +0
     DISPLAY 'NUMBER OF ROWS DELETED' SQLERRD(3)
     DISPLAY 'SQLCODE = ' SQLCODE
     DISPLAY '*** DELETE SUCCESSFUL ***'
  ELSE
      IF SQLCODE = +100
          DISPLAY 'SQLCODE = ' SQLCODE
          DISPLAY '*** NO ROWS TO DELETE ***'
          [b][i][u]GO TO 1000-EXIT[/u][/i][/b] -> won't go to else part if 100
      ELSE
          IF SQLCODE NOT = +0
              DISPLAY 'SQLCODE = ' SQLCODE
              DISPLAY '*** DELETE FAILED ***'
              MOVE 4 TO RETURN-CODE
              GO TO 1000-EXIT
          END-IF
      END-IF
 END-IF.

1000-EXIT.
EXIT.


It will come out if value is 100 to 1000-EXIT and will not go to ELSE as if condition itself is satisfied.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri May 30, 2008 3:04 pm
Reply with quote

If Sqlcode = 100 it will not execute sqlcode not = 0 because of the GO TO statment.

Why dont you rewrite this for better readability

Code:


Evaluate Sqlcode

when 0
.....
.....
when 100
....
...

when other
....
....

End-Evaluate.
Back to top
View user's profile Send private message
kumar1234

New User


Joined: 06 Nov 2007
Posts: 84
Location: bangalore

PostPosted: Fri May 30, 2008 3:14 pm
Reply with quote

Hi,

Thanks a lot for clarifying me on this doubt.

Thanks,
Kumar.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts How to load to DB2 with column level ... DB2 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top