RDB/VMS Relational Database Operator START_SEGMENT — VMS RDB_3.1A
START_SEGMENTED_STRING
Starts a stream of segmented string segments within a record stream.
To end the stream, use the END_SEGMENTED_STRING statement.
Example (Callable RDO):
START_STREAM STREAM USING R IN RESUMES
FETCH STREAM
START_SEGMENTED_STRING STRING USING T IN R.RESUME
GET !VAL = T.RDB$VALUE;
!VAL = T.RDB$LENGTH
END_GET
END_SEGMENTED_STRING STRING
END_STREAM STREAM
Additional information available:
More
Starts a stream of segmented string segments within a record stream. Retrieving records with segmented string fields requires a kind of "segment stream" within a record stream. This second stream is normally established by nesting a special segmented string FOR loop inside another FOR loop. However, in certain cases, you cannot or may not want to use FOR loops (as in Callable RDO programs). The START_SEGMENTED_STRING statement is similar to the START_STREAM statement: it starts a "stream" of string segments. You do not use a FETCH statement to retrieve each segment. The PRINT or GET statement retrieves the segment and advances the pointer to the next segment. At the end of the stream, Rdb/VMS returns an end-of-stream message, SEGSTR_EOF. To end the stream, use the END_SEGMENTED_STREAM statement.
Format
STARTSEGMENTEDSTRING ─> ss-handle ─┐ ┌─────────────────────────────────────┘ └───>
U
S
I
N
G ────┬─────>─────────┬─────┐ └──> on-error ──┘ │ ┌─────────────────────────────────────┘ └─> context-var ───>
I
N ──> ss-field
Additional information available:
ss-handleon-errorcontext-varss-field
ss-handle
A host language variable or name used to refer to the segmented string.
on-error
The ON ERROR clause, which specifies host language statements or Rdb/VMS data manipulation statements to be performed if an Rdb/VMS error occurs. For more information, request HELP on ON_ERROR.
context-var
A valid context variable. You use this context variable to qualify the segments in the data manipulation statements that follow.
ss-field
A qualified field name that refers to a field defined with the segmented string data type. Note that this field name must be qualified by its own context variable. This second context variable must match the variable declared in the START_STREAM statement.
Example
INVOKE DATABASE FILENAME 'PERSONNEL'
START_STREAM STREAM USING R IN RESUMES
FETCH STREAM
START_SEGMENTED_STRING STRING USING T IN R.RESUME
GET !VAL = F.RDB$VALUE;
!VAL = F.RDB$LENGTH
END_GET
END_SEGMENTED_STRING STRING
END_STREAM STREAM
This example:
o Starts a stream with the stream name STREAM. END_STREAM STREAM
closes the block.
o Uses the FETCH statement to move the stream pointer to the first
record in the relation RELNAME.
o Uses START_SEGMENTED_STRING to start a stream of segments from
the RESUME field of RESUMES. Note that the context variable (R)
on RESUME relates it to RESUMES.
o Uses GET to retrieve each segment and its length. The second
context variable relates each segment value to the segmented
string field, RESUME. The COBOL program displays the results.
o Encloses both the FETCH and the GET in loops. This outer and
inner looping structure is necessary to retrieve each record and
each segment within RESUME.
For a more extensive example, see the VAX Rdb/VMS Reference Manual.