上面查询用的完整语句是:
SELECT gcc.*
FROM {APPS.gl_code_combinations } gcc
WHERE GCC.SEGMENT1 = 'T'
and GCC.SEGMENT2 = 'T'
and GCC.SEGMENT4 = 'T'
and GCC.SEGMENT3 not in (1000, 2000, 5100, 5101, 5400, 5401,3000)
and GCC.SEGMENT5 = 'T'
and GCC.SEGMENT6 = 'T'
and GCC.SEGMENT7 = 'T'
查询不到结果的语句是:
SELECT hao.name 公司名称,
hao.internal_address_line 公司代码,
gb.period_name 期间名称,
GCC.SEGMENT3 || ' ' || j.description 科目,
j.description 科目名称,
GCC.SEGMENT3 科目代码,
decode(j.structured_hierarchy_level, 8, '一级科目',5,'二级科目', 6,'三级科目', '四级科目') 科目级次,
gb.begin_balance_dr - gb.begin_balance_cr 期初数,
gb.period_net_dr 本期借方发生额,
gb.period_net_cr 本期贷方发生额,
gb.period_net_dr - gb.period_net_cr 本期净额,
gb.begin_balance_dr - gb.begin_balance_cr +gb.period_net_dr-gb.period_net_cr 期末数
FROM {APPS.gl_balances} gb,{APPS.gl_code_combinations} gcc,{APPS.hr_all_organization_units} hao,{APPS.FND_FLEX_VALUES_VL} J
WHERE GCC.CODE_COMBINATION_ID = GB.CODE_COMBINATION_ID
and gcc.segment3 = j.flex_value
and j.Flex_Value_Set_Id = '1007062'
AND GCC.SEGMENT1 = 'T'
and GCC.SEGMENT2 = 'T'
and gcc.segment1 = hao.internal_address_line
and hao.name like 'OU%'
and GCC.SEGMENT4 = 'T'
and GCC.SEGMENT3 not in (1000, 2000, 5100, 5101, 5400, 5401,3000)
and GCC.SEGMENT5 = 'T'
and GCC.SEGMENT6 = 'T'
and GCC.SEGMENT7 = 'T'
and gb.actual_flag = 'A'
and gb.period_name = 'JUN-11'
ORDER BY 2,6
如果将上面查询不到结果的语句换成:
SELECT hao.name 公司名称,
hao.internal_address_line 公司代码,
gb.period_name 期间名称,
GCC.SEGMENT3 || ' ' || j.description 科目,
j.description 科目名称,
GCC.SEGMENT3 科目代码,
decode(j.structured_hierarchy_level, 8, '一级科目',5,'二级科目', 6,'三级科目', '四级科目') 科目级次,
gb.begin_balance_dr - gb.begin_balance_cr 期初数,
gb.period_net_dr 本期借方发生额,
gb.period_net_cr 本期贷方发生额,
gb.period_net_dr - gb.period_net_cr 本期净额,
gb.begin_balance_dr - gb.begin_balance_cr +gb.period_net_dr-gb.period_net_cr 期末数
FROM {APPS.gl_balances} gb,{APPS.gl_code_combinations} gcc,{APPS.hr_all_organization_units} hao,{APPS.FND_FLEX_VALUES_VL} J
WHERE GCC.CODE_COMBINATION_ID = GB.CODE_COMBINATION_ID
and gcc.segment3 = j.flex_value
and j.Flex_Value_Set_Id = '1007062'
AND GCC.SEGMENT1 = '3610'
and GCC.SEGMENT2 = 'T'
and gcc.segment1 = hao.internal_address_line
and hao.name like 'OU%'
and GCC.SEGMENT4 = 'T'
and GCC.SEGMENT3 not in (1000, 2000, 5100, 5101, 5400, 5401,3000)
and GCC.SEGMENT5 = 'T'
and GCC.SEGMENT6 = 'T'
and GCC.SEGMENT7 = 'T'
and gb.actual_flag = 'A'
and gb.period_name = 'JUN-11'
ORDER BY 2,6
又可以查询到想要的结果,真的不知道具体的原因。
上面两段语句如果通过pl/sql查询,都可以查询到想要的结果。