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
 

 

How does Perform With Test After work

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
SSR
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 38

PostPosted: Wed Dec 27, 2006 6:32 pm    Post subject: How does Perform With Test After work
Reply with quote

Hi,

Could anyone please explain me what does the below code does.

PERFORM WITH TEST AFTER
UNTIL SQLCODE NOT = -911
EXEC SQL
Query.
END-EXEC

How does 'PERFORM WITH TEST AFTER' work?

Regards
SSR
Back to top
View user's profile Send private message

sandeep1dimri

New User


Joined: 30 Oct 2006
Posts: 76

PostPosted: Wed Dec 27, 2006 7:42 pm    Post subject:
Reply with quote

Perform the statement first
EXEC SQL
Query.
END-EXEC

Then check the condition
SQLCODE NOT = -911
In any case the statements get executed once.

Sandeep
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Dec 27, 2006 8:36 pm    Post subject: Re: How does Perform With Test After work
Reply with quote

Hi SSR,

To Add to ?Sandeep?s? post.

The normal (default) mode for PERFORMs is ?WITH TEST BEFORE? and works like this:

Code:

PERFORM
  Test conditions, exit Perform loop if true
    :
    Perform statements   
    :
  Increment variables
  Go to top of Perform Loop


This is why, if you want to perform the loop 10 times, you would code
?VARYING SUB FROM 1 BY 1 UNTIL SUB > 10?
because the 10th time through the perform loop ?SUB? has a value of 10 when the condition is tested at the top of the Perform loop and you would exit after performing the loop only 9 times if you coded SUB = 10

The optional mode for PERFORMs is ?WITH TEST AFTER? and works like this:

Code:

PERFORM
    :
    Perform statements
    :
  Test condition, exit Perform loop if true
  Increment variables
  Go to top of perform Loop


In this case, if you want to perform the loop 10 times, you would code
?VARYING SUB FROM 1 BY 1 UNTIL SUB = 10?
because the test for conditions is done at the bottom of the perform loop, just before the variables are incremented and you have already executed the PERFORM loop where SUB = 10.

In the example you gave at the top, if SQLCODE = 000 at the start of the PERFORM loop, and you used the default (?WITH TEST BEFORE?), you could never execute your SQL, the condition would be true the first time through. With the optional ?WITH TEST AFTER? the test is done at the end of the PERFORM loop, and as ?Sandeep? stated your SQL is executed at least one time
Back to top
View user's profile Send private message
SSR
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 38

PostPosted: Fri Dec 29, 2006 2:08 pm    Post subject: Re: How does Perform With Test After work
Reply with quote

Hi,

Thank you,

Is PERFORM WITH TEST BEFORE EQUIVALENT TO PERFORM UNTIL OPTION, OR THE PERFORM WITH TEST BEFORE/AFTER NEEDS TO BE USED ALONG WITH UNTIL OPTION.

Regards
SSR
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2284
Location: @my desk

PostPosted: Fri Dec 29, 2006 3:04 pm    Post subject:
Reply with quote

Hi SSR,

Quote:
Is PERFORM WITH TEST BEFORE EQUIVALENT TO PERFORM UNTIL OPTION, OR THE PERFORM WITH TEST BEFORE/AFTER NEEDS TO BE USED ALONG WITH UNTIL OPTION.


You need to specify the UNTIL condition also along with the PERFORM WITH TEST AFTER phrase.PERFORM WITH TEST BEFORE UNTIL 'condn' is equivalent to PERFORM UNTIL 'condn'.You should not omit the UNTIL phrase in either case.

Thanks
Arun
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid 2 commands instream work. In ... descann Compuware & Other Tools 2 Tue May 16, 2017 3:31 pm
No new posts COOLGEN - TSO TEST FACILITY indianrajput CA Products 4 Wed Nov 02, 2016 9:28 pm
This topic is locked: you cannot edit posts or make replies. How to supply called sub-program from... dchristensen JCL & VSAM 25 Wed Sep 14, 2016 11:36 pm
No new posts How to perform Digest Access Authenti... vasanthz All Other Mainframe Topics 0 Tue Mar 15, 2016 4:47 pm
No new posts What is the maximum number of sort wo... Pravina M SYNCSORT 2 Mon Mar 14, 2016 4:51 pm


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