Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: If SQL code + 100 will it execute both the conditions shown
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    Post subject:
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    Post subject:
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    Post subject: Reply to: doubt in SQL
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm
No new posts Job failing with USER = 4093 REASON C... Pradeepa S ABENDS & Debugging 1 Wed May 17, 2017 3:35 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us