READ ... THRU with superdescriptor



Software AG's platform-independent programming language with full support for open-source and Internet applications

READ ... THRU with superdescriptor

Postby RGZbrog » Tue Nov 24, 2009 11:46 am

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.
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: READ ... THRU with superdescriptor

Postby dick scherrer » Wed Nov 25, 2009 12:32 am

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
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: READ ... THRU with superdescriptor

Postby RGZbrog » Wed Nov 25, 2009 12:46 am

Dick,

I've tried both RGZbrog and Ralph Zbrog.
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: READ ... THRU with superdescriptor

Postby dick scherrer » Wed Nov 25, 2009 1:42 am

Hi Ralph,

Which would you prefer? I'll ask one be activated and the other removed.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: READ ... THRU with superdescriptor

Postby RGZbrog » Wed Nov 25, 2009 1:56 am

Keep the full name, Ralph Zbrog, please. I don't use nicknames, even on the Web.

And, Thanks!
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: READ ... THRU with superdescriptor

Postby dick scherrer » Wed Nov 25, 2009 3:47 am

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
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: READ ... THRU with superdescriptor

Postby RGZbrog » Mon Nov 30, 2009 8:32 am

Dick,

I've heard nothing. Please follow-up.
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: READ ... THRU with superdescriptor

Postby dick scherrer » Mon Nov 30, 2009 9:45 am

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
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: READ ... THRU with superdescriptor

Postby RGZbrog » Fri Dec 04, 2009 3:01 pm

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.
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: READ ... THRU with superdescriptor

Postby dick scherrer » Wed Dec 09, 2009 12:12 am

Hi Ralph,

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

Again, sorry 'bout the delay. . .

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Next

Return to Natural

 


  • Related topics
    Replies
    Views
    Last post