The problem is as follows:
Www.2cto.com
Actual test conditions: -- create table G_PRODUCT_REL (PRODUCT_ID NUMBER not null, -- Business id PC_ID NUMBER not null -- business category id) SELECT 'insert INTO G_PRODUCT_REL (PRODUCT_ID, PC_ID)
VALUES ('| G. PRODUCT_ID |', '| G. PC_ID |') 'FROM G_PRODUCT_REL G;
The test data is as follows: www.2cto.com
Example 1: select g. PRODUCT_ID, strcat (G. PC_ID) FROM G_PRODUCT
_ Rel g group by g. PRODUCT_ID; -- category of each business www.2cto.com
Example 2: SELECT PC_ID, STRCAT (G. PRODUCT_ID) FROM G_PRODUCT _
Rel g group by g. PC_ID; -- there are services www.2cto.com in each category
The following three SQL statements CREATE this FUNCTION: Using CREATE OR REPLACE FUNCTION strcat (input VARCHAR2)
RETURN VARCHAR2 PARALLEL_ENABLE aggregate using strcat_type; Specify create or replace type strcat_type as object (currentstr varchar2 (4000), currentseprator varchar2 (8), static function compute (sctx in out strcat_type) return number, member function ODCIAggregateIterate (self IN OUT
Strcat_type, value IN VARCHAR2) return number, member function odciaggresponterminate (self IN strcat _
Type, returnValue OUT VARCHAR2, flags IN number) return number, member function ODCIAggregateMerge (self in out strcat_type,
Ctx2 IN strcat_type) return number) specify create or replace type body strcat_type is static function odciaggresponinitialize (sctx in out strcat_type) return number is begin sctx: = strcat_type ('',', '); return ODCIConst. success; end; member function ODCIAggregateIterate (self in out strcat_type,
Value IN VARCHAR2) return number is begin if self. currentstr is null then self. currentstr: = value; else self. currentstr: = self. currentstr | currentseprator | value; end if; return ODCIConst. success; end; member function odciaggresponterminate (self IN strcat_type,
ReturnValue OUT VARCHAR2, flags IN number) return number is begin returnValue: = self. currentstr; return ODCIConst. Success; end; member function ODCIAggregateMerge (self in out strcat_type,
Ctx2 IN strcat_type) return number is begin if ctx2.currentstr is null then self. currentstr: = self. currentstr; elsif self. currentstr is null then self. currentstr: = ctx2.currentstr; else self. currentstr: = self. currentstr | currentseprator | ctx2.currentstr; end if; return ODCIConst. success; end; the above functions are written by our DBA, but now more than 10 Gb of database has been added
The wm_concat (column) function merges fields. Haha