Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 5 Wed Oct 04, 2017 6:54 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 47 Fri Sep 29, 2017 1:08 pm
No new posts Speed-up/reduce CPU use of code prino PL/I & Assembler 0 Tue Sep 26, 2017 12:05 am
This topic is locked: you cannot edit posts or make replies. how to code for GDG in Rexx cvnlynn CLIST & REXX 13 Wed Aug 09, 2017 9:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us