Access Collection PL / SQL

时间:2016-06-10 15:34:17

标签: plsql plsqldeveloper

这是我想要了解的pl / sql查询:

TYPE REC_ASSMNTCOMP IS RECORD (RF_CUST_ID_REF NUMBER, RF_TIMESTAMP DATE, RF_BC_ID_REF NUMBER, RF_OP_COMPVALUE NUMBER);
TYPE TBL_ASSMNTCOMP_T IS TABLE OF REC_ASSMNTCOMP INDEX BY PLS_INTEGER;
TYPE TBL_ASSMNTCOMP IS TABLE OF TBL_ASSMNTCOMP_T INDEX BY PLS_INTEGER;

TYPE REC_ADJCOMP IS RECORD (RF_CUST_ID_REF NUMBER, RF_TIMESTAMP DATE, RF_BC_ID_REF NUMBER, RF_ADJ_COMPVALUE NUMBER);
TYPE TBL_ADJCOMP_T IS TABLE OF REC_ADJCOMP INDEX BY PLS_INTEGER;

TYPE REC_OPENCOMP IS RECORD (RF_BILLCYC_ID_REF NUMBER, RF_CUST_ID_REF NUMBER, RF_COMPTYPE NUMBER, RF_BC_ID_REF NUMBER, RF_COMPVALUE NUMBER);
TYPE TBL_OPENCOMP IS TABLE OF REC_OPENCOMP INDEX BY PLS_INTEGER;

V_DOC_ID                NUMBER;
V_PROCESSING_DATE       DATE;

V_TBL_ASSMNTCOMP        TBL_ASSMNTCOMP;
V_TBL_ASSMNTCOMP_T      TBL_ASSMNTCOMP_T;

V_TBL_ADJCOMP_T         TBL_ADJCOMP_T;

V_TBL_OPENCOMP          TBL_OPENCOMP;


IF V_TBL_ADJCOMP_T(I).RF_TIMESTAMP < V_TBL_ASSMNTCOMP(V_TBL_ADJCOMP_T(I).RF_CUST_ID_REF)(V_TBL_ASSMNTCOMP(V_TBL_ADJCOMP_T(I).RF_CUST_ID_REF).FIRST).RF_TIMESTAMP
   THEN

令人困惑的部分如下:

V_TBL_ASSMNTCOMP(V_TBL_ADJCOMP_T(I).RF_CUST_ID_REF)(V_TBL_ASSMNTCOMP(V_TBL_ADJCOMP_T(I).RF_CUST_ID_REF).FIRST).RF_TIMESTAMP

上面的行是做什么的?

1 个答案:

答案 0 :(得分:1)

它可以重写为:

-- (Declare IDX NUMBER)
-- Get the RF_CUST_ID_REF from the I'th V_TBL_ADJCOMP_T record
IDX := V_TBL_ADJCOMP_T(I).RF_CUST_ID_REF;   

-- (Declare REC with same type as rows of V_TBL_ASSMNTCOMP)
-- Get the V_TBL_ASSMNTCOMP record indexed by that RF_CUST_ID_REF 
REC := V_TBL_ASSMNTCOMP(IDX);

IF V_TBL_ADJCOMP_T(I).RF_TIMESTAMP < REC(REC.FIRST).RF_TIMESTAMP THEN...

这对我来说仍然没有多大意义,但也许对你而言?似乎V_TBL_ASSMNTCOMP是一个表,其结构包括另一个表 - 即上面声明的REC I是一个表和V_TBL_ASSMNTCOMP中的一行?

请参阅this PDF,了解Steven Feuerstein对我认为您可能正在处理的“多层次”收藏品的解释。