View previous topic :: View next topic
|
Author |
Message |
monasu1998
Active User
Joined: 23 Dec 2005 Posts: 176 Location: India
|
|
|
|
Hi,
This question comes from an interviewer.
Why ENDING AT/THRU can not be used with superdescriptor?
Can somebody help me in answering this question? |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
As far as I know, there's no such limitation. May be you meant hyperdescriptors?
O. |
|
Back to top |
|
|
monasu1998
Active User
Joined: 23 Dec 2005 Posts: 176 Location: India
|
|
|
|
Yes. I agree to your point. Otherwise usually we use the ENDING A/THRU with the superdescriptors only.
This makes me to think.
Why such restrictions for hyperdescriptors? I did not work on this descriptor any time. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
That's easy: Hyperdescriptor is used to generate descriptor values based on a user-supplied algorithm.
Since the ENDING clause is handled by ADABAS, and since ADABAS can't tell the next value of a user-defined sequence, hence you can't use it for hyperdescriptors.
O. |
|
Back to top |
|
|
monasu1998
Active User
Joined: 23 Dec 2005 Posts: 176 Location: India
|
|
|
|
Thats cool. Good to know about it. Thank you. |
|
Back to top |
|
|
Steve Robinson
New User
Joined: 14 Nov 2009 Posts: 12 Location: U.S.
|
|
|
|
A correction to earlier post.
Adabas does not deal with ENDING AT clauses; Natural does.
Adabas does deal with Hyper Descriptors.
So, since Natural does not have access to Hyper Descriptors, it cannot use same in an ENDING AT clause.
steve |
|
Back to top |
|
|
Ralph Zbrog
New User
Joined: 21 Nov 2009 Posts: 58 Location: California
|
|
|
|
Since no one challenged the responses, it looks like you all failed the interview! Well, this particular question, anyway. This may be due in part to the interviewer being misquoted - see below.
First, as to hyperdescriptors, their values may be generated in a non-Natural way (a user exit coded in Assembler), but they are treated by Natural just like a superdescriptor, and can be used anywhere a super is used.
The interviewer's question applies not only to superdescriptors, but also to subdescriptors and hyperdescriptors. It probably was phrased, "When can THRU not be used with a superdescriptor?", rather than why.
Here's a working example of FROM/THRU, using subdescriptor DEPARTMENT in the EMPLOYEES demo file.
Code: |
DEFINE DATA LOCAL
1 EMP VIEW EMPLOYEES
2 PERSONNEL-ID
2 DEPT
2 DEPARTMENT /* For use by THRU
END-DEFINE
R.
READ EMP BY DEPARTMENT FROM 'ADMA'
THRU 'ADMA'
DISPLAY DEPT (AL=4)
PERSONNEL-ID
* UPDATE (R.)
END-READ
END |
For the THRU clause (I find the synonym ENDING AT too wordy), Natural needs memory locations in which to place the "retrieved" descriptor value, so that a comparison can be made to the value provided (THRU 'ADMA'). In this example, it means that the subdescriptor, DEPARTMENT, must be included in the view.
What happens when the UPDATE statement is reinstated? Adabas will try to update each field in the view, but Natural knows that the subdescriptor does not actually exist as a field in the EMPLOYEES file, so he issues a NAT0633 at compile-time.
Quote: |
NAT0633 Invalid use of view which contains super-/subdescriptor. |
To answer the interviewer's question
Quote: |
You cannot code THRU with a sub/super/hyper-descriptor in an update READ loop. |
To keep the UPDATE, the corrective action is to remove the descriptor from the view. For Natural 3, you replace the THRU with an IF ... ESCAPE BOTTOM statement block to test for the end of range. For Natural 4, you replace the THRU with TO, which does not require the descriptor definition in the view because Adabas tests for the end of range. |
|
Back to top |
|
|
|