问题标题:
不理解oracle的function是怎么用的,CREATEORREPLACETYPEobj_NA_Issued_Exclude_NILNAASOBJECT(TOTAL_CASESVARCHAR2(500),OBJECTED_CASESVARCHAR2(500),NA_ISSUED_MONTHVARCHAR2(20),PERCENTAGEVARCHAR2(12),MET_TARGETVARCHAR2(10))/CREATEORRE
问题描述:

不理解oracle的function是怎么用的,

CREATEORREPLACETYPEobj_NA_Issued_Exclude_NILNA

ASOBJECT

(

TOTAL_CASESVARCHAR2(500),

OBJECTED_CASESVARCHAR2(500),

NA_ISSUED_MONTHVARCHAR2(20),

PERCENTAGEVARCHAR2(12),

MET_TARGETVARCHAR2(10)

)

/

CREATEORREPLACETYPEtbl_NA_Issued_Exclude_NILNA

ASTABLEOFobj_NA_Issued_Exclude_NILNA

/

FUNCTIONgetNAIssuedExcludeNILNA(

NAIssuedDateFromVARCHAR2,

NAIssuedDateToVARCHAR2,

KPIObjectionRateVARCHAR2)

RETURNtbl_NA_Issued_Exclude_NILNA

IS

NA_Issued_Exclude_NILNA_TBLtbl_NA_Issued_Exclude_NILNA:=tbl_NA_Issued_Exclude_NILNA();

CURSORNA_Issued_Exclude_NILNA_CURIS

SELECT*FROMDUAL;

BEGIN

FORNA_Issued_Exclude_NILNA_RECINNA_Issued_Exclude_NILNA_CUR

LOOP

NA_Issued_Exclude_NILNA_TBL.EXTEND;

NA_Issued_Exclude_NILNA_TBL(NA_Issued_Exclude_NILNA_TBL.LAST):=obj_NA_Issued_Exclude_NILNA(NA_Issued_Exclude_NILNA_REC.TOTAL_CASES,NA_Issued_Exclude_NILNA_REC.OBJECTED_CASES,NA_Issued_Exclude_NILNA_REC.NA_ISSUED_MONTH,NA_Issued_Exclude_NILNA_REC.PERCENTAGE,NA_Issued_Exclude_NILNA_REC.MET_TARGET);

ENDLOOP;

RETURNNA_Issued_Exclude_NILNA_TBL;

--EndFunction

ENDgetNAIssuedExcludeNILNA;

林英回答:
  这是个对象表的例子.   FUNCTIONgetNAIssuedExcludeNILNA(   NAIssuedDateFromVARCHAR2,   NAIssuedDateToVARCHAR2,   KPIObjectionRateVARCHAR2)   RETURNtbl_NA_Issued_Exclude_NILNA   声明函数getNAIssuedExcludeNILNA(),参数为...,返回值为tbl_NA_Issued_Exclude_NILNA类型(对象表).   IS   NA_Issued_Exclude_NILNA_TBLtbl_NA_Issued_Exclude_NILNA:=tbl_NA_Issued_Exclude_NILNA();   CURSORNA_Issued_Exclude_NILNA_CURIS   SELECT*FROMDUAL;   初始化参数:tbl_NA_Issued_Exclude_NILNA为对象表NA_Issued_Exclude_NILNA_TBL的实例;NA_Issued_Exclude_NILNA_CUR为一个游标.   BEGIN   FORNA_Issued_Exclude_NILNA_RECINNA_Issued_Exclude_NILNA_CUR   LOOP   NA_Issued_Exclude_NILNA_TBL.EXTEND;   NA_Issued_Exclude_NILNA_TBL(NA_Issued_Exclude_NILNA_TBL.LAST):=obj_NA_Issued_Exclude_NILNA(NA_Issued_Exclude_NILNA_REC.TOTAL_CASES,NA_Issued_Exclude_NILNA_REC.OBJECTED_CASES,NA_Issued_Exclude_NILNA_REC.NA_ISSUED_MONTH,NA_Issued_Exclude_NILNA_REC.PERCENTAGE,NA_Issued_Exclude_NILNA_REC.MET_TARGET);   ENDLOOP;   函数的主体:   循环:每次从NA_Issued_Exclude_NILNA_CUR中取出一条记录到NA_Issued_Exclude_NILNA_REC中.   循环内部:NA_Issued_Exclude_NILNA_TBL.EXTEND;将对象表的实例扩展一条.   NA_Issued_Exclude_NILNA_TBL(NA_Issued_Exclude_NILNA_TBL.LAST):=obj_NA_Issued_Exclude_NILNA(NA_Issued_Exclude_NILNA_REC.TOTAL_CASES,NA_Issued_Exclude_NILNA_REC.OBJECTED_CASES,NA_Issued_Exclude_NILNA_REC.NA_ISSUED_MONTH,NA_Issued_Exclude_NILNA_REC.PERCENTAGE,NA_Issued_Exclude_NILNA_REC.MET_TARGET);   为对象表实例的最后一条(刚刚扩展出来的)赋值.   RETURNNA_Issued_Exclude_NILNA_TBL;   返回对象表的实例NA_Issued_Exclude_NILNA_TBL.   函数体结束.
查看更多
其它推荐
热门其它推荐