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
 

 

Tricky Question in NATURAL

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> Java & MQSeries
View previous topic :: :: View next topic  
Author Message
atulrukmangad

New User


Joined: 10 Apr 2006
Posts: 13

PostPosted: Tue May 02, 2006 10:09 am    Post subject: Tricky Question in NATURAL
Reply with quote

This was asked in an interview.

What will be the result of the following and why ?

READ (10) EMPLOY-VIEW WITH EMPLOY-ID = '3'
ACCEPT IF EMPLOY-ID = '3'
REJECT IF EMPLOY-ID ='3'
WRITE EMPLOY-ID
END-READ

Assume that EMPLOY-ID =3 exists in the EMPLOYEE table.
Back to top
View user's profile Send private message

skodidine

New User


Joined: 05 Apr 2006
Posts: 6

PostPosted: Tue May 02, 2006 9:53 pm    Post subject: Re: Tricky Question in NATURAL
Reply with quote

if records exist with EMPLOY-ID = '3' within the first 10 READS, then they will be written because:

"If an ACCEPT condition is satisfied, the record will be accepted and consecutive ACCEPT/REJECT statements will be ignored."

Sanjay
Back to top
View user's profile Send private message
rahul_mf
Warnings : 1

New User


Joined: 13 Sep 2005
Posts: 13

PostPosted: Wed May 03, 2006 1:25 pm    Post subject: Re: Tricky Question in NATURAL
Reply with quote

Sanjay , you are absolutely right.

But I dont know why you have written:-
"if records exist with EMPLOY-ID = '3' within the first 10 READS"

Because the statement :-
READ (10) EMPLOY-VIEW WITH EMPLOY-ID = '3'

Means that it will read those first 10 records which satisfy the condition
EMPLOY-ID = '3' .
Back to top
View user's profile Send private message
skodidine

New User


Joined: 05 Apr 2006
Posts: 6

PostPosted: Wed May 03, 2006 8:57 pm    Post subject: Re: Tricky Question in NATURAL
Reply with quote

ooops!! Sorry, didnt read the statement correctly, yes it will pick up the first 10 records that have EMPLOY-ID = '3'. My mistake.

Sanjay
Back to top
View user's profile Send private message
rahul_mf
Warnings : 1

New User


Joined: 13 Sep 2005
Posts: 13

PostPosted: Thu May 04, 2006 8:00 am    Post subject: Re: Tricky Question in NATURAL
Reply with quote

No probs icon_wink.gif
Back to top
View user's profile Send private message
Bidzoniy

New User


Joined: 04 May 2006
Posts: 1

PostPosted: Sat May 06, 2006 7:07 am    Post subject: Natural Interview Questions
Reply with quote

Can somebody provide the list of the possible Natural/Adabas interview questions (at leat some of them) or point me where I can find them

Thanks
Back to top
View user's profile Send private message
naveen_desireddy

New User


Joined: 29 Aug 2005
Posts: 10
Location: Hyderabad, India

PostPosted: Tue May 23, 2006 1:58 am    Post subject:
Reply with quote

if records exist with EMPLOY-ID = '3' within the first 10 READS, then they will be written because:

"If an ACCEPT condition is satisfied, the all the record's will be accepted
irrespective of other conditions
Back to top
View user's profile Send private message
Sid Reddy

New User


Joined: 28 May 2009
Posts: 2
Location: Chennai

PostPosted: Fri May 29, 2009 7:06 pm    Post subject: Re: Tricky Question in NATURAL
Reply with quote

Rahul, for your below quote/issue i think its a bit incorrect... it does not mean that it will read first 10 records mtching employ id =3. it will start reading from employ id=3

Quote:
But I dont know why you have written:-
"if records exist with EMPLOY-ID = '3' within the first 10 READS"

Because the statement :-
READ (10) EMPLOY-VIEW WITH EMPLOY-ID = '3'

Means that it will read those first 10 records which satisfy the condition
EMPLOY-ID = '3' .




icon_question.gif i think you got the concept of read incorrectly... i understand that even you give the statement "EQUAL TO" it is equivalent to "starting from"

hope i am correct... in that case the first answer stand correct.... will display 3 if the record is found in first 10 read loops.

Please correct me if i am wrong
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Sat May 30, 2009 10:54 pm    Post subject:
Reply with quote

Sid Reddy - Hello and welcome to the forum.

Have you noticed that you were replying a 3-years post?

O.
Back to top
View user's profile Send private message
Sid Reddy

New User


Joined: 28 May 2009
Posts: 2
Location: Chennai

PostPosted: Mon Jun 01, 2009 8:16 pm    Post subject:
Reply with quote

ofer71 wrote:
Sid Reddy - Hello and welcome to the forum.

Have you noticed that you were replying a 3-years post?

O.


Yes,

I knew it. I just wanted to correct something that I felt was guiding people wrong... many of my friends visited this site and pointed to this...
Back to top
View user's profile Send private message
Steve Robinson

New User


Joined: 14 Nov 2009
Posts: 12
Location: U.S.

PostPosted: Sun Nov 15, 2009 11:07 pm    Post subject:
Reply with quote

Sad to say, but every answer to this question is incorrect.

Lets see why.

READ (10) EMPLOY-VIEW WITH EMPLOY-ID = '3'

The more readable version of the READ would be:

READ (10) EMPLOY-VIEW BY EMPLOY-ID STARTING FROM '3'

Although legal syntax, WITH is very misleading here. STARTING FROM is the self explanatory syntax.


ACCEPT IF EMPLOY-ID = '3'
REJECT IF EMPLOY-ID ='3'



This is the tricky piece of the code. Whenever there are two or more ACCEPT/REJECTs together the code works totally different than if the statements were not contiguous.

What happens is:

Natural does the first ACCEPT/REJECT. If true, Natural does the "action" part of the statement, then skips the remainder of the tests in the "group". If false, Natural proceeds to the next test and repeats this action.

HENCE, ALL records pass these two statements.

WRITE EMPLOY-ID
END-READ

So, the output might look like:


3
3
3
3
4
4
4
5
5
6

There will ALWAYS be ten lines of output (the limit factor of ten on the READ). The numbers will be in ascending sequence since we are reading by EMPLOY-ID. They might all be 3's, or none of them might be 3.

steve
[/i]
Back to top
View user's profile Send private message
monasu1998

Active User


Joined: 23 Dec 2005
Posts: 176
Location: India

PostPosted: Tue Nov 17, 2009 10:28 pm    Post subject:
Reply with quote

Hi Steve,

I had a wrong thought about consecutive Accept/reject statements.

But after reading thru your post, I am clear.

I never thought of the DISPLAYs for the EMP-ID NOT = 3.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> Java & MQSeries All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
This topic is locked: you cannot edit posts or make replies. Natural ADABAS Opening with CTS enikhilk Mainframe Jobs 0 Wed Nov 30, 2016 5:37 pm


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