Table of Contents

Search

  1. Preface
  2. Function reference
  3. Constants
  4. Operators
  5. Dates
  6. Functions
  7. System variables
  8. Datatype reference

Function Reference

Function Reference

Nested struct

Nested struct

A nested struct is a struct that contains one or more levels of structs. You can use a dot operator to access a primitive element in a struct at the innermost level. You can also use a dot operator to access a struct at any level.
You can use dot operators to return the following values:
  • A primitive element in a struct at the innermost level.
  • One or more structs at any level.
To access a primitive element in a struct at the innermost level, you use more than one dot operator. The number of levels in a nested struct determines the number of dot operators to use. The data type of the return value is the same as the data type of the element in the struct.
For example, in a nested struct with two levels of structs, you use two dot operators. The first dot operator accesses the parent struct to locate the child struct. Then, the second dot operator accesses the child struct to return a specific primitive element in the child struct.

Example

You have the following struct
employee_info_struct
that contains two child structs
home_address_info
and
department_info
:
employee_info_struct{ emp_name: 'Derrick' home_address_info{ city: 'New York' state: NULL department_info{ NULL } }
The following expressions use dot operators to access values from the struct
employee_info_struct
:
Input Value
RETURN VALUE
employee_info_struct.emp_name
'Derrick'
employee_info_struct.home_address_info
{ city: 'New York' state: NULL }
employee_info_struct.department_info
NULL
employee_info_struct.home_address_info.city
'New York'
employee_info_struct.home_address_info.state
NULL

0 COMMENTS

We’d like to hear from you!