View previous topic :: View next topic
|
Author |
Message |
kumar1234
New User
Joined: 06 Nov 2007 Posts: 84 Location: bangalore
|
|
|
|
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 |
|
|
abhishekmdwivedi
New User
Joined: 22 Aug 2006 Posts: 95 Location: india
|
|
|
|
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 |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
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 |
|
|
kumar1234
New User
Joined: 06 Nov 2007 Posts: 84 Location: bangalore
|
|
|
|
Hi,
Thanks a lot for clarifying me on this doubt.
Thanks,
Kumar. |
|
Back to top |
|
|
|