Method invocation

Both system-generated observer and mutator methods, as well as user-defined methods are invoked using the double-dot operator.

method-invocation
Read syntax diagramSkip visual syntax diagramsubject-expression..method-name (,expression)
subject-expression
An expression with a static result type that is a user-defined structured type.
method-name
The unqualified name of a method. The static type of subject-expression or one of its supertypes must include a method with the specified name.
(expression,...)
The arguments of method-name are specified within parentheses. Empty parentheses can be used to indicate that there are no arguments. The method-name and the data types of the specified argument expressions are used to resolve to the specific method, based on the static type of subject-expression.
The double-dot operator used for method invocation is a high precedence left to right infix operator. For example, the following two expressions are equivalent:
   a..b..c + x..y..z
and
   ((a..b)..c) + ((x..y)..z)
If a method has no parameters other than its subject, it can be invoked with or without parentheses. For example, the following two expressions are equivalent:
   point1..x
   point1..x()
Null subjects in method calls are handled as follows:
  • If a system-generated mutator method is invoked with a null subject, an error results (SQLSTATE 2202D)
  • If any method other than a system-generated mutator is invoked with a null subject, the method is not executed, and its result is null. This rule includes user-defined methods with SELF AS RESULT.

When a database object (a package, view, or trigger, for example) is created, the best fit method that exists for each of its method invocations is found.

Note: Methods of types defined WITH FUNCTION ACCESS can also be invoked using the regular function notation. Function resolution considers all functions, as well as methods with function access as candidate functions. However, functions cannot be invoked using method invocation. Method resolution considers all methods and does not consider functions as candidate methods. Failure to resolve to an appropriate function or method results in an error (SQLSTATE 42884).

Example

  • Use the double-dot operator to invoke a method called AREA. Assume the existence of a table called RINGS, with a column CIRCLE_COL of structured type CIRCLE. Also, assume that the method AREA has been defined previously for the CIRCLE type as AREA() RETURNS DOUBLE.
       SELECT CIRCLE_COL..AREA() FROM RINGS