DB2 Arrays, functions

Source: Internet
Author: User

One. Arrays

In DB2, creating an array will generate two objects under functions: The SYS type and the user type array

/* Create an array */ Create  as varchar (+) array[]; /* Delete an array */ drop type arrname;

Two. Functions

1. Basic syntax

Create functionDB2INST.FUNC1 (param1integer, param2varchar(Ten))/*input Parameters except Boolean and cursor*/returns varchar( $)/*must return type, optional scalar,row,table*/specific "func1" language SQL notdeterministicexternal actionmodifies SQL databegin    DeclareVarNamevarchar( $); /*use of custom arrays*/    Declarearr1 Arrname; SetArr1=Array[' 2 ']; returnVarName;End
View Code

 

2. Common functions

cardinality (ARR1): Returns the number of elements in an array locate (ARG1,ARG2,<pos>) : Find where Arg1 first appears in Arg2, and if POS is specified, find the location where ARG1 first appears, starting at POS at arg2. COALESCE (Arg1,arg2 ...) : Returns the first non-null parameter in a parameter set. Usage is similar to the value function. substr (Arg1,pos,<length>): Returns the length character at the beginning of the POS position in arg1, if no length is specified, The remaining characters are returned. Integer (ARG1): Returns the converted integer cast (<expression><DataType  >[length]): Data type conversion function sum (ARG1): The value of the column is counted

DB2 Array, function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.