The ORACLE String concatenation aggregate function can be used for group

Source: Internet
Author: User

The ORACLE String concatenation aggregate function can be used for group by 1. create type strcat_type www.2cto.com -- the essence of defining a type aggregate function is an object create or replace type strcat_type as object (cat_string varchar2 (4000), -- object initializes static function odciaggresponinitialize (cs_ctx In Out strcat_type) return number, -- Iteration Method of the aggregate function (this is the most important method) member function ODCIAggregateIterate (self In Out strcat_type, value in varchar2) return number, -- when the query statement is executed and handed In, this method can be applied to aggregate multiple running query results into member function ODCIAggregateMerge (self In Out strcat_type, ctx2 In Out strcat_type) return number, -- terminate the processing penalty of the collection function and return the result of the collection function processing penalty. member function odciaggresponterminate (self In Out strcat_type, returnValue Out varchar2, flags in number) return number) 2. build type body strcat_type www.2cto.com create or replace type body strcat_type is static function ODCIAggregateInitialize (cs_ctx in out strcat_type) return number is begin cs_ctx: = strcat_type (null); return ODCIConst. success; end; member function ODCIAggregateIterate (self in out strcat_type, value IN varchar2) return number is begin/* string already "", "respectively */self. cat_string: = self. cat_string | "", "" | value; return ODCIConst. success; end; member function odciaggresponterminate (self IN Out strcat_type, returnValue OUT varchar2, flags IN number) return number is begin/* remove null (is null) */returnValue: = ltrim (rtrim (self. cat_string, "", ""), "", ""); return ODCIConst. success; end; member function ODCIAggregateMerge (self in out strcat_type, ctx2 IN Out strcat_type) return number is begin self. cat_string: = self. cat_string | "", "" | ctx2.cat _ string; return ODCIConst. success; end; www.2cto.com 3. build FUNCTION func_strcat create or replace function func_strcat (input varchar2) RETURN varchar2 -- RETURN Value PARALLEL_ENABLE aggregate using strcat_type; -- accumulate parallel 4. result * t_test t; id keyword synonyms 1 coffee shop 2 coffee house 3 coffee shop 4 music popular music 5 music classical music 6 life livelihood comfortable living livelihood 7 life livelihood _________________________________ t. keyword, func_strcat (t. synonyms) t_test t group by t. keyword; keyword func_strcat (t. synonyms) coffee shops, coffee houses, coffee shops, and coffee shops for a comfortable life and livelihood, as well as popular music and classical music
 

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.