2022-12-29

[Oracle]How to query account description

以下範例為六個節段,第三節段與第四節段相依
SELECT FFVV1.DESCRIPTION || '-' || FFVV2.DESCRIPTION || '-' ||
             FFVV3.DESCRIPTION || '-' || FFVV4.DESCRIPTION || '-' ||
             FFVV5.DESCRIPTION || '-' || FFVV6.DESCRIPTION
        FROM GL_CODE_COMBINATIONS_V GCC,
             FND_ID_FLEX_SEGMENTS   FIFSV1,
             FND_FLEX_VALUES_VL     FFVV1,
             FND_ID_FLEX_SEGMENTS   FIFSV2,
             FND_FLEX_VALUES_VL     FFVV2,
             FND_ID_FLEX_SEGMENTS   FIFSV3,
             FND_FLEX_VALUES_VL     FFVV3,
             FND_ID_FLEX_SEGMENTS   FIFSV4,
             FND_FLEX_VALUES_VL     FFVV4,
             FND_ID_FLEX_SEGMENTS   FIFSV5,
             FND_FLEX_VALUES_VL     FFVV5,
             FND_ID_FLEX_SEGMENTS   FIFSV6,
             FND_FLEX_VALUES_VL     FFVV6
       WHERE 1 = 1
         AND GCC.CODE_COMBINATION_ID = CID
         AND FIFSV1.ID_FLEX_CODE = 'GLLE'
         AND FIFSV2.ID_FLEX_CODE = 'GLLE'
         AND FIFSV3.ID_FLEX_CODE = 'GLLE'
         AND FIFSV4.ID_FLEX_CODE = 'GLLE'
         AND FIFSV5.ID_FLEX_CODE = 'GLLE'
         AND FIFSV6.ID_FLEX_CODE = 'GLLE'
         AND GCC.CHART_OF_ACCOUNTS_ID = FIFSV1.ID_FLEX_NUM
         AND FIFSV1.FLEX_VALUE_SET_ID = FFVV1.FLEX_VALUE_SET_ID
         AND FFVV1.FLEX_VALUE = GCC.SEGMENT1
         AND FIFSV1.SEGMENT_NUM = 2
         AND GCC.CHART_OF_ACCOUNTS_ID = FIFSV2.ID_FLEX_NUM
         AND FIFSV2.FLEX_VALUE_SET_ID = FFVV2.FLEX_VALUE_SET_ID
         AND FFVV2.FLEX_VALUE = GCC.SEGMENT2
         AND FIFSV2.SEGMENT_NUM = 3
         AND GCC.CHART_OF_ACCOUNTS_ID = FIFSV3.ID_FLEX_NUM
         AND FIFSV3.FLEX_VALUE_SET_ID = FFVV3.FLEX_VALUE_SET_ID
         AND FFVV3.FLEX_VALUE = GCC.SEGMENT3
         AND FIFSV3.SEGMENT_NUM = 4
         AND GCC.CHART_OF_ACCOUNTS_ID = FIFSV4.ID_FLEX_NUM
         AND FIFSV4.FLEX_VALUE_SET_ID = FFVV4.FLEX_VALUE_SET_ID
         AND FFVV4.FLEX_VALUE = GCC.SEGMENT4
         AND FFVV4.PARENT_FLEX_VALUE_LOW = FFVV3.FLEX_VALUE_MEANING --Depends Key Point
         AND FIFSV4.SEGMENT_NUM = 5
         AND GCC.CHART_OF_ACCOUNTS_ID = FIFSV5.ID_FLEX_NUM
         AND FIFSV5.FLEX_VALUE_SET_ID = FFVV5.FLEX_VALUE_SET_ID
         AND FFVV5.FLEX_VALUE = GCC.SEGMENT5
         AND FIFSV5.SEGMENT_NUM = 6
         AND GCC.CHART_OF_ACCOUNTS_ID = FIFSV6.ID_FLEX_NUM
         AND FIFSV6.FLEX_VALUE_SET_ID = FFVV6.FLEX_VALUE_SET_ID
         AND FFVV6.FLEX_VALUE = GCC.SEGMENT6
         AND FIFSV6.SEGMENT_NUM = 7;

沒有留言:

張貼留言