以下的文章主要是对Oracle合并函数的两种类型的介绍,即,Oracle9i与Oracle10g相关实际应用代码的介绍,以及Oracle9i的具体使用方案的描述,下面就是文章的具体内容的介绍,望你会有所收获。
Oracle合并函数之9i下:
createtypestrcat_typeasobject( cat_stringvarchar2(4000), staticfunctionODCIAggregateInitialize(cs_ctxInOutstrcat_type)returnnumber, memberfunctionODCIAggregateIterate(selfInOutstrcat_type,valueinvarchar2)returnnumber, memberfunctionODCIAggregateMerge(selfInOutstrcat_type,ctx2InOutstrcat_type)returnnumber, memberfunctionODCIAggregateTerminate(selfInOutstrcat_type,returnValueOutvarchar2,flagsinnumber)returnnumber ) / createtypebodystrcat_typeis staticfunctionODCIAggregateInitialize(cs_ctxINOUTstrcat_type)returnnumber is begin cs_ctx:=strcat_type(null); returnODCIConst.Success; end; memberfunctionODCIAggregateIterate(selfINOUTstrcat_type, valueINvarchar2) returnnumber is begin self.cat_string:=self.cat_string||','||value; returnODCIConst.Success; end; memberfunctionODCIAggregateTerminate(selfINOutstrcat_type, returnValueOUTvarchar2, flagsINnumber) returnnumber is begin returnValue:=ltrim(rtrim(self.cat_string,','),','); returnODCIConst.Success; end; memberfunctionODCIAggregateMerge(selfINOUTstrcat_type, ctx2INOutstrcat_type) returnnumber is begin self.cat_string:=self.cat_string||','||ctx2.cat_string; returnODCIConst.Success; end; end; / CREATEorreplace FUNCTIONstrcat(inputvarchar2) RETURNvarchar2 PARALLEL_ENABLEAGGREGATEUSINGstrcat_type; /
使用方法:
selectt2.kdm_mdid_pk,t2.kdm_title, strcat(t3.subject_mc_content)message fromt_knodoc_rel_subjectst1, T_KNO_DOC_METADATAt2, T_SUBJECT_MULTILINGUAL_CONTENTt3 wheret1.krs_kdm_mdid_fk=t2.kdm_mdid_pk andt1.krs_subid_fk=t3.subject_mc_id_pk groupbyt2.kdm_mdid_pk,t2.kdm_title
Oracle合并函数之10g下:
selectt2.kdm_mdid_pk,t2.kdm_title,WMSYS.WM_CONCAT(t3.subject_mc_content)message fromt_knodoc_rel_subjectst1, T_KNO_DOC_METADATAt2, T_SUBJECT_MULTILINGUAL_CONTENTt3 wheret1.krs_kdm_mdid_fk=t2.kdm_mdid_pk andt1.krs_subid_fk=t3.subject_mc_id_pk groupbyt2.kdm_mdid_pk,t2.kdm_title
相关文章
标签:Oracle