View previous topic :: View next topic
|
Author |
Message |
Gatbys
New User
Joined: 04 May 2008 Posts: 3 Location: Stockholm, Sweden
|
|
|
|
Hi,
I am an entry level programmer in Natural/ADABAS.
I would like to know how to use GET Statement while accessing ADABAS files.
Thanks a lot for your time.
Cheers,
Gatbys. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
The GET statement is well documented in Software AG's manual: Natural Statements, with great exaplanation and pretty good examples.
O. |
|
Back to top |
|
|
nikipathak
New User
Joined: 16 Jul 2009 Posts: 3 Location: pune
|
|
|
|
Get statement is used to make avaialable a record for processing when the isn is known.
get is mostly used with in a READ or FIND loop to get the ISN number like
DEFINE DATA LOCAL
1 PERSONS VIEW OF EMPLOYEES
2 PERSONNEL-ID
2 NAME
2 FIRST-NAME
1 SALARY-INFO VIEW OF EMPLOYEES
2 NAME
2 CURR-CODE (1:1)
2 SALARY (1:1)
1 #ISN-ARRAY (B4/1:10)
1 #LINE-NR ( N2)
END-DEFINE
/********************************************************************
FORMAT PS=16
LIMIT 10
READ PERSONS BY NAME
MOVE *COUNTER TO #LINE-NR
MOVE *ISN TO #ISN-ARRAY (#LINE-NR)
DISPLAY #LINE-NR PERSONNEL-ID NAME FIRST-NAME
/********************************************************************
AT END OF PAGE
INPUT / ’PLEASE SELECT LINE-NR FOR SALARY INFORMATION:’ #LINE-NR
IF #LINE-NR = 1 THRU 10
GET SALARY-INFO #ISN-ARRAY (#LINE-NR)
WRITE / SALARY-INFO.NAME
SALARY-INFO.SALARY (1)
SALARY-INFO.CURR-CODE (1)
END-IF
END-ENDPAGE
END-READ
END |
|
Back to top |
|
|
Steve Robinson
New User
Joined: 14 Nov 2009 Posts: 12 Location: U.S.
|
|
|
|
The main use of GET is in conjunction with UPDATE.
Consider the following code (which is potentially poor code)
READ ....
IF ... some rare condition
::::
UPDATE
END-IF
END-READ
Problem. The Natural compiler looks at this code and realizes that any record read by the READ statement might be updated. Hence, the READ generates a read with hold to Adabas, rather than a simple read.
Assuming very few records get updated, this will almost certainly lead to an error message regardign an overflow of the record hold queue.
Instead, one typically codes:
READR. READ ....
IF ... some rare condition
::::
GETR. GET ... *ISN (READR.)
UPDATE (GETR.)
END-IF
END-READ
Now the READ at READR. is a simple read, not a read with hold. (since there are no UPDATE statements that reference the READ)
The read that results from the GET is a read with hold (since the UPDATE references the GET).
There would probably be an END TRANSACTION after the UPDATE (although this might be controlled by a counter; but then you would have to worry about an ET timeout).
steve |
|
Back to top |
|
|
|