You invoke a constructor method to create and initialize a new instance of a structured UDT and you invoke an instance method on an existing instance of a distinct or structured UDT.
Argument List
The arguments in the method invocation must appear as comma-separated expressions in the same order as the parameters in the METHOD specification of the CREATE TYPE statement.
The arguments in the method invocation must be compatible with the parameter declarations in the method definition of an existing method, and must fit into the compatible type without a possible loss of information. For example, a BYTEINT argument in a method invocation is compatible with an INTEGER parameter declaration in the method definition, and also fits into the INTEGER type without any loss of information.
To pass an argument that is not compatible with the corresponding parameter type, explicitly convert the argument to the proper type in the method invocation.
The NULL keyword is compatible with a parameter of any data type. For more information on the behavior of NULL as a literal argument, see Argument Behavior.
For information on compatible types and the precedence rules, see UDM Parameters.
The RETURNS and RETURNS STYLE Clauses
When invoking a UDM that is defined with a TD_ANYTYPE return parameter, you can use the RETURNS data type or RETURNS STYLE column expression clauses to specify the desired return type. The column expression can be any valid table or view column reference, and the return data type is determined based on the type of the column.
The RETURNS or RETURNS STYLE clause is not mandatory as long as the method also includes a TD_ANYTYPE input parameter. If you do not specify a RETURNS or RETURNS STYLE clause, then the data type of the first TD_ANYTYPE input argument is used to determine the return type of the TD_ANYTYPE return parameter. For character types, if the character set is not specified as part of the data type, then the default character set is used.
Note that you must enclose the UDM invocation in parenthesis if you use the RETURNS or RETURNS STYLE clauses.
Method Selection
When you use a METHOD specification in a CREATE TYPE statement, the database takes the UDT name, method name, and method parameter list to form an internal method name and parameter list that looks like this:
method_name(UDT_name, parameter_1 … , parameter_n)
Similarly, when you invoke a method on a UDT, the database uses the UDT name, method name, and method argument list to form an internal method name and argument list that looks like this:
method_name(UDT_name, argument_1 … , argument_n)
Vantage searches the database for an internal method and parameter list that matches the internal method and argument list in the method invocation.
IF such a method … | THEN … |
---|---|
exists, and the arguments in the method invocation are compatible with the method parameters and follow the order of precedence | the search stops. If several methods have the same name, Vantage follows the same rules to determine which method to invoke that it uses to determine which function to invoke if several UDFs have the same name. For details, see Overloaded Function Invocation. |
does not exist, or the arguments in the method invocation are not compatible with the method parameters | the statement returns an error. |
For the rules of compatibility precedence, see UDM Parameters.
Overloaded Method Invocation
If several UDMs have the same name, Vantage follows the same rules to determine which method to invoke that it uses to determine which function to invoke if several UDFs have the same name.
For details, see Overloaded Function Invocation.
Related Information
FOR more information on … | SEE … |
---|---|
example SQL statements that invoke instance and constructor methods |
|
instance and constructor method invocation syntax | Teradata Vantage™ - SQL Operators and User-Defined Functions, B035-1210. |
using the NEW expression to construct UDT instances | |
restrictions that apply to instance and constructor method invocation |