$rettype

Return the retrieval mode of the outermost entity.

$rettype

Return Values

Values returned by $rettype
Trigger Value Meaning
  "" An error occurred. $procerror contains a negative value that identifies the exact error.
create  65 Add occurrence
73 Insert occurrence
Read 43 Retrieve additional occurrences (retrieve/a)
58 Retrieve one additional occurrence (retrieve/x)
78 Next occurrence
82 Retrieve
84 Reconnect (retrieve/reconnect)
110 Retrieve sequential
Values of $procerror Commonly Returned Following $rettype
Value  Error constant Meaning
-1304 <UPROCERR_UNKNOWN_CONTEXT>

Function not allowed, unknown context. For example, $rettype was encountered outside the create and read triggers.

Use

Allowed in all component types.

Description

The function $rettype returns the retrieval mode of the outermost entity. It should be used only in the read trigger or the create trigger.

$rettype is set by the read ProcScript statement and the ^ADD_OCC and ^INS_OCC structure editor functions.

Conditional Processing for read

For example, query parameters are only used on the first read statement to generate the database select instruction. On consequent reads these parameters are ignored. so you can use $rettype==78 ( Next occurrence) to prevent unnecessary code execution for potential query parameter processing.

trigger read
  if ($rettype != 78)
    ; Construct query and order information here
    read u_where (something…) order by ….
  else
   ; No need to construct any query and order info, because it is ignored for subsequent occurrences
    read
  endif
end

Related Topics