KeyEQ (Dataset function): Difference between revisions
RPuszewski (talk | contribs) (Created page with "{{Template:Dataset:KeyEQ subtitle}} ==Syntax== {{Template:Dataset:KeyEQ syntax}} ===Syntax terms=== <table class="syntaxTable"> <tr><th>dataset</th> <td>Position to a specifi...") |
RPuszewski (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
{{Template:Dataset:KeyEQ subtitle}} | {{Template:Dataset:KeyEQ subtitle}} | ||
This function sets the read position of a VSAM dataset to the record key specified. A subsequent read of the <var>Dataset</var> object will return the specified record. | |||
==Syntax== | ==Syntax== | ||
{{Template:Dataset:KeyEQ syntax}} | {{Template:Dataset:KeyEQ syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th> | <tr><th>%boolean</th> | ||
<td>A variable to receive the result of the position function of the <var class="term">dataset</var> object. | |||
</td></tr> | |||
<td>A | <tr><th>Key</th> | ||
<td>The value used to position the <var>Dataset</var> object. | |||
</td></tr> | |||
<tr><th> | |||
<td>The | |||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | |||
<li>The default for <var>Key</var> is nulls. | |||
Setting the value to nulls will cause reads to begin from the first record.</li>. | |||
</ul> | |||
==Examples== | ==Examples== | ||
ALLOCATE DATASET VSAMALT WITH SCOPE=SYSTEM DSN=RDP.VSAM.AIX - | |||
VSAM KEYED OLD SHARE | |||
ALLOCATE DATASET VSAMDS WITH SCOPE=SYSTEM DSN=RDP.VSAM - | |||
VSAM KEYED OLD SHARE | |||
Begin | |||
%l is longstring | |||
%ds is object dataset | |||
%ds = new('VSAMALT') | |||
if %ds:open then | |||
print "Error opening dataset" | |||
stop | |||
end if | |||
%key is string len 4 initial('AAAA') | |||
print %ds:keyeq(%key) | |||
%l = %ds:readRecord | |||
%ds:close | |||
%ds = new('VSAMDS') | |||
if %ds:open then | |||
print "Error opening dataset" | |||
stop | |||
end if | |||
print %ds:keyge(%l:Substring(10,8)) | |||
repeat forever | |||
%l = %ds:readRecord | |||
if %ds:state eq afterEnd then | |||
print 'end of rec' | |||
loop end | |||
end if | |||
print %l | |||
end repeat | |||
%ds:close | |||
End | |||
FREE VSAMALT | |||
FREE VSAMDS | |||
==See also== | ==See also== | ||
{{Template:Dataset: | {{Template:Dataset:KeyEQ footer}} |
Revision as of 16:06, 14 April 2021
Template:Dataset:KeyEQ subtitle
This function sets the read position of a VSAM dataset to the record key specified. A subsequent read of the Dataset object will return the specified record.
Syntax
Syntax
Template loop detected: Template:Dataset:KeyEQ syntax
Syntax terms
%boolean | A Boolean enumeration value |
---|---|
key | A key object. |
Syntax terms
%boolean | A variable to receive the result of the position function of the dataset object. |
---|---|
Key | The value used to position the Dataset object. |
Usage notes
- The default for Key is nulls. Setting the value to nulls will cause reads to begin from the first record. .
Examples
ALLOCATE DATASET VSAMALT WITH SCOPE=SYSTEM DSN=RDP.VSAM.AIX - VSAM KEYED OLD SHARE ALLOCATE DATASET VSAMDS WITH SCOPE=SYSTEM DSN=RDP.VSAM - VSAM KEYED OLD SHARE Begin %l is longstring %ds is object dataset %ds = new('VSAMALT') if %ds:open then print "Error opening dataset" stop end if %key is string len 4 initial('AAAA') print %ds:keyeq(%key) %l = %ds:readRecord %ds:close %ds = new('VSAMDS') if %ds:open then print "Error opening dataset" stop end if print %ds:keyge(%l:Substring(10,8)) repeat forever %l = %ds:readRecord if %ds:state eq afterEnd then print 'end of rec' loop end end if print %l end repeat %ds:close End FREE VSAMALT FREE VSAMDS