DELETE SEGMENT, REPLACE SEGMENT, and SELECT SEGMENT statements


After the SAMPLE statements select records to include in the output file; and the INCLUDE SEGMENTS and EXCLUDE SEGMENTS statements identify which record segment types to include in the output file; the DELETE SEGMENT, REPLACE SEGMENT, and SELECT SEGMENT statements determine the individual segments to include in the output file.

If no SAMPLE, INCLUDE SEGMENTS, or EXCLUDE SEGMENTS statements were specified, all of the segments in the database are processed by the DELETE SEGMENT, REPLACE SEGMENT, and SELECT SEGMENT statements.

Usage

There is no default output when a segment type is in the sample. To get output, you must use one or more REPLACE SEGMENT or SELECT SEGMENT statements. After all of the DELETE SEGMENT, REPLACE SEGMENT, and SELECT SEGMENT statements a processed, specify SELECT (*), to include all of the remaining segments.

When a segment is deleted, its children and all their dependents are also deleted and cannot be replaced or selected.

A segment name can be specified only once on a DELETE SEGMENT, REPLACE SEGMENT, and SELECT SEGMENT statements. That is, a segment name cannot be specified in more than one statement, and it cannot be specified in multiple occurrences of the same statement.

DELETE SEGMENT statement

The DELETE SEGMENT statement specifies an individual segment you want deleted from the output file. When you delete a segment, you are also deleting the dependents for the segment from the output file.

The DELETE SEGMENT statement formats are:

 DELETE SEGMENT (segmentName)
DELETE SEGMENT (segmentName WHEN (conditionalExpression))

If you are deleting more than one segment, you specify the DELETE SEGMENT statement for each segment that you want to delete.

You can only specify DELETE SEGMENT once for a segment name.

Use WHEN to specify a condition under which to delete the named segment.

Without specifying a WHEN condition, all segments of that type are deleted.

For more information about the values you can use for the variables, see EXTCMDS-command-language-expressions.

Information
Example
DELETE SEGMENT (CUSTSEG)

Deletes all CUSTSEG segments and their dependents.

Information
Example
DELETE SEGMENT (CUSTSEG WHEN (ROOTSEG.COUNTRY EQ C'USA'))

Deletes CUSTSEG segments that are dependents of ROOTSEG segments with a COUNTRY field of USA.

REPLACE SEGMENT statement

The REPLACE SEGMENT statement specifies an individual segment you want to replace in the output file.

The REPLACE SEGMENT statement formats are:

REPLACE SEGMENT (segmentName) WITH (FIELD ((expression)))
 REPLACE SEGMENT (segmentName) WITH (FIELD ((expression))) WHEN (conditionalExpression))

Specify the information to replace a segment by using FIELD keywords in the WITH clause based on criteria defined by the WHEN clause.

If you are replacing more than one segment, specify a REPLACE SEGMENT statement for each segment you want to replace.

You can only specify REPLACE SEGMENT once for each segment name.

For more information about the values you can use for the variables, see EXTCMDS-command-language-expressions.

Information
Example
REPLACE SEGMENT (CUSTSEG)
        WITH (
              FIELD((LASTNAME))
              FIELD((C' IS FROM '))
              FIELD((ROOTSEG.COUNTRY))
              )
        )

Replaces all CUSTSEG segments with the contents of the LASTNAME field, the words IS FROM, and the contents of the ROOTSEG.COUNTRY segment: SMITH IS FROM USA.

Information
Example
REPLACE SEGMENT (CUSTSEG)
        WITH (
              FIELD((LASTNAME))
              FIELD((C' IS FROM '))
              FIELD((ROOTSEG.COUNTRY))
              )
        WHEN (ROOTSEG.COUNTRY EQ C'USA')
        )

Replaces all CUSTSEG segments with the contents of the LASTNAME field, the words IS FROM, and the contents of the ROOTSEG.COUNTRY segment if ROOTSEG.COUNTRY contains USA.

If a CUSTSEG segment does not meet the WHEN conditions, it does not change.

SELECT SEGMENT statement

The SELECT SEGMENT statement specifies the segments to include in the output file. The WHEN clause follows the same rules as under the SAMPLE keyword, except all fields within all segments in the hierarchical path back to the root are available for reference.

The SELECT SETMENT formats are:

 SELECT SEGMENT (segmentName)
SELECT SEGMENT (segmentName WHEN (conditionalExpression))

When using the WHEN clause, you can use all fields within all segments in the hierarchical path back to the root.

For more information about the values you can use for the variables, see EXTCMDS-command-language-expressions.

Information
Example
SELECT SEGMENT (CUSTSEG)

Includes all CUSTSEG segments in the output file.

Information
Example
SELECT SEGMENT (CUSTSEG WHEN (LASTNAME EQ C'SMITH'))

Includes only CUSTSEG segments when the LASTNAME field contains SMITH. The field could be a field in the CUSTSEG segment or any field in the path to the root segment.

Information
Example
SELECT SEGMENT (CUSTSEG WHEN (CUSTSEG.LASTNAME EQ C'SMITH'))

It can be useful to explicitly qualify a field by the segment that contains it, for instance when two segments in the same path share a field name. To do this, specify the field by segmentName.fieldName.

Includes only CUSTSEG segments when the LASTNAME field in the CUSTSEG segment contains SMITH.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC AMI Online Reorg for IMS 5.2