Page 1 of 2

READ ... THRU with superdescriptor

PostPosted: Tue Nov 24, 2009 11:46 am
by RGZbrog
On November 11, a question was posted at IBMMAINFRAMES.com Support Forums -> NATURAL & MQSERIES, regarding a Natural/Adabas interview question. Wanting to respond to the posting, I registered with the forum, but after a week, my account is still inactive. :cry: Perhaps I didn't fill out the form properly. Nonetheless, here is my response. Perhaps someone will cross-post to the other forum.

The posting quoted an interviewer as asking, "Why ENDING AT/THRU can not be used with superdescriptor?"

There were only two responses, discussing how the interviewer must have been referring to hyperdescriptors. You should review that thread before you continue reading here.

================================================

Well, the poster and the two respondents all failed the interview! ;) Well, this particular question, anyway.

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.

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 ('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 error NAT0633 at compile-time.

To answer the interviewer's question, "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.

Re: READ ... THRU with superdescriptor

PostPosted: Wed Nov 25, 2009 12:32 am
by dick scherrer
Hello and welcome to the forum,

Which Id did you register "over there"?

If it is still not activated, i'll ask the Admin to correct. Sometimes it does take more than a week to activate a new Id.

Sorry for the delay,

d

Re: READ ... THRU with superdescriptor

PostPosted: Wed Nov 25, 2009 12:46 am
by RGZbrog
Dick,

I've tried both RGZbrog and Ralph Zbrog.

Re: READ ... THRU with superdescriptor

PostPosted: Wed Nov 25, 2009 1:42 am
by dick scherrer
Hi Ralph,

Which would you prefer? I'll ask one be activated and the other removed.

Re: READ ... THRU with superdescriptor

PostPosted: Wed Nov 25, 2009 1:56 am
by RGZbrog
Keep the full name, Ralph Zbrog, please. I don't use nicknames, even on the Web.

And, Thanks!

Re: READ ... THRU with superdescriptor

PostPosted: Wed Nov 25, 2009 3:47 am
by dick scherrer
Hi Ralph,

I've sent a note to the admin and will hopefully hear something soon.

If your id has not been activated by this weekend, post a reply and i'll follow-up.

d

Re: READ ... THRU with superdescriptor

PostPosted: Mon Nov 30, 2009 8:32 am
by RGZbrog
Dick,

I've heard nothing. Please follow-up.

Re: READ ... THRU with superdescriptor

PostPosted: Mon Nov 30, 2009 9:45 am
by dick scherrer
Hi Ralph,

I just sent a followup to the site admin. Unfortunately, i am not able to do this.

Please keep me posted if the id is not working in a few days. . . (Or when it is :) ).

d

Re: READ ... THRU with superdescriptor

PostPosted: Fri Dec 04, 2009 3:01 pm
by RGZbrog
The automated e-mail response to my registration indicated up to a 3-day waiting period for activation. It's been 3 weeks, so I give up.

As usual, I'll be posting on Software AG's Developer Forum and invite you all to join me there: http://tech.forums.softwareag.com.

Re: READ ... THRU with superdescriptor

PostPosted: Wed Dec 09, 2009 12:12 am
by dick scherrer
Hi Ralph,

Give it a try now - i just rec'd confirmation from the admin. . .

Again, sorry 'bout the delay. . .

d