Oracle EBS R12报表的Oracle弹性值层次结构SQL查询

4ioopgfo  于 2022-09-18  发布在  Java
关注(0)|答案(3)|浏览(210)

我刚接触甲骨文和甲骨文EBS,我需要一些帮助。

我正在Oracle EBS r12中做报告,我需要使用SQL查询以分层的方式列出fnd_flex_Values_VL视图中的flex值。它不一定非得是分层查询。任何查询都可以。我只需要一个SQL语句,它将以其层次结构的方式返回给我弹性值。

有两个对象,它们存储有关弹性值层次结构的信息。它是FND_FLEX_VALUE_NORM_Hierarchy(表)和FND_FLEX_VALUE_CHILDS_V(视图)。我认为其中一个就足够了,因为fnd_flex_Value_Child_v是使用FND_flex_Value_Norm_Hierarchy和其他一些对象创建的。

然而,我面临的问题是,几个父项可能被列出为一个弹性值,并且我需要找到所有顶级父项或叶,以便进行自上而下或自下而上的层次结构。据我所知,FND_FLEX_VALUE_CHILDS_V不一定存储顶级父母(只存储孩子)。

此外,似乎可能没有一个层次结构,但可能有多个层次结构(如果是这样的话,我需要在一个查询中列出它们)。

您的帮助我们将不胜感激。我已经为这个问题挣扎了很长时间了。非常感谢您的关注。

致以最诚挚的问候,新用户。=)

agxfikkp

agxfikkp1#

您应该使用表格APPLSYS.FND_FLEX_VALUE_SETS。您标识的对象是关于FND_FLEX_VALUE_SETS表的元数据对象。

我喜欢从根记录开始。

下面是我查找根记录(无父记录)的方法。

SELECT DISTINCT
FVS.PARENT_FLEX_VALUE_SET_ID
FROM
APPLSYS.FND_FLEX_VALUE_SETS FVS
WHERE
FVS.PARENT_FLEX_VALUE_SET_ID  IS NOT NULL 
ORDER BY 1 ;

一旦我找到根记录,我就开发我的START BY子句:

START WITH
(
FVS.FLEX_VALUE_SET_ID IN
(SELECT DISTINCT FVS.PARENT_FLEX_VALUE_SET_ID
FROM APPLSYS.FND_FLEX_VALUE_SETS FVS
WHERE FVS.PARENT_FLEX_VALUE_SET_ID IS NOT NULL
)

此子句确实捕获所有根记录(您可以只选择一个)。

接下来,我将开发我的CONNECT BY子句。由于我希望我的层次结构从根开始,因此我将采用以下方法:

级别1 flex_value_set_id...以前的级别

第2级父级_flex_value_set_id

CONNECT BY fvs.parent_flex_value_set_id = prior fvs.flex_value_set_id ;

这将导致以下声明:

SELECT LEVEL,
FVS.*
FROM APPLSYS.FND_FLEX_VALUE_SETS FVS
START WITH
(
FVS.FLEX_VALUE_SET_ID IN
(SELECT DISTINCT FVS.PARENT_FLEX_VALUE_SET_ID
FROM APPLSYS.FND_FLEX_VALUE_SETS FVS
WHERE FVS.parent_flex_value_set_id IS NOT NULL
)
)
CONNECT BY FVS.PARENT_FLEX_VALUE_SET_ID = PRIOR FVS.FLEX_VALUE_SET_ID ;

然后,用户可以按如下方式添加弹性值:

SELECT  
LEVEL, 
FVS.* 
FROM  
(SELECT 
 FLEX.FLEX_VALUE_SET_ID, 
 FLEX.PARENT_FLEX_VALUE_SET_ID, 
 FLEX.FLEX_VALUE_SET_NAME, 
 FVAL.FLEX_VALUE 
 FROM 
 APPLSYS.FND_FLEX_VALUE_SETS FLEX, 
 APPLSYS.FND_FLEX_VALUES FVAL 
 WHERE 
 FLEX.FLEX_VALUE_SET_ID = FVAL.FLEX_VALUE_SET_ID(+)) FVS 
 START WITH 
 (FVS.FLEX_VALUE_SET_ID IN 
  (SELECT DISTINCT 
   FVS.PARENT_FLEX_VALUE_SET_ID 
   FROM APPLSYS.FND_FLEX_VALUE_SETS FVS 
   WHERE FVS.parent_flex_value_set_id IS NOT NULL ) ) 
   CONNECT BY 
   FVS.PARENT_FLEX_VALUE_SET_ID = PRIOR FVS.FLEX_VALUE_SET_ID;
whlutmcx

whlutmcx2#

也许这对你有帮助

SELECT fvc.PARENT_FLEX_VALUE RUBRO_N0 ,FVT.description
DESC_RUBRO_N0,FVC.FLEX_VALUE RUBRO_N1 , fvc.DESCRIPTION
DESC_RUBRO_N1,FVC2.FLEX_VALUE RUBRO_N2 , FVC2.DESCRIPTION
DESC_RUBRO_N2,FVC3.FLEX_VALUE RUBRO_N3 , FVC3.DESCRIPTION
DESC_RUBRO_N3,FVC4.FLEX_VALUE RUBRO_N4 , FVC4.DESCRIPTION
DESC_RUBRO_N4,NVL(FVC4.FLEX_VALUE,NVL(FVC3.FLEX_VALUE,NVL(FVC2.FLEX_VALUE,FVC.FLEX_VALUE))) RUBROFIN
FROM FND_FLEX_VALUE_CHILDREN_V fvc 
,FND_FLEX_VALUE_CHILDREN_V FVC2 
,FND_FLEX_VALUE_CHILDREN_V FVC3 
,FND_FLEX_VALUE_CHILDREN_V FVC4
,FND_FLEX_VALUES_TL FVT 
WHERE fvc.FLEX_VALUE_SET_ID =  1016176 
AND fvc.PARENT_FLEX_VALUE not in(SELECT FLEX_VALUE FROM FND_FLEX_VALUE_CHILDREN_V WHERE FLEX_VALUE_SET_ID = --YOUR FLEX_VALUE_SET_ID) 
AND fvc.FLEX_VALUE = FVC2.PARENT_FLEX_VALUE (+) 
AND fvc2.FLEX_VALUE = FVC3.PARENT_FLEX_VALUE (+) 
AND fvc3.FLEX_VALUE  = FVC4.PARENT_FLEX_VALUE (+) 
AND fvc.PARENT_FLEX_VALUE = FVT.FLEX_VALUE_MEANING 
AND FVT.SOURCE_LANG = 'ESA'
AND FVT.LANGUAGE = 'ESA' AND FVT.LAST_UPDATE_LOGIN NOT IN (0) 
ORDER BY 1,2,3,5,7
;

诚挚的问候

ndh0cuux

ndh0cuux3#

Blitz报告库中的这条SQL返回基于fnd_flex_Value_Norm_Hierarchy的层次结构,其中包含所有的子flex值:https://www.enginatics.com/reports/fnd-flex-value-hierarchy/

select
lpad(' ',2*(level-1))||level level_,
lpad(' ',2*(level-1))||ffvnh.parent_flex_value value,
ffvv.description,
decode(ffvnh.range_attribute,'P','Parent','C','Child') range_attribute,
ffvnh.child_flex_value_low,
ffvnh.child_flex_value_high,
decode(connect_by_isleaf,1,'Yes') is_leaf,
connect_by_root ffvnh.parent_flex_value root_value,
substr(sys_connect_by_path(ffvnh.parent_flex_value,'-> '),4) path,
ffvnh.parent_flex_value value_flat
from
(
select
ffvnh.parent_flex_value,
ffvnh.child_flex_value_low,
ffvnh.child_flex_value_high,
ffvnh.range_attribute,
ffvnh.flex_value_set_id
from
fnd_flex_value_norm_hierarchy ffvnh
where
ffvnh.flex_value_set_id=(select ffvs.flex_value_set_id from fnd_flex_value_sets ffvs where ffvs.flex_value_set_name=:flex_value_set_name)
union all
select
ffv2.flex_value parent_flex_value,
null child_flex_value_low,
null child_flex_value_high,
'x' range_attribute,
ffv2.flex_value_set_id
from
fnd_flex_values ffv2
where
2=2 and
ffv2.summary_flag='N' and
ffv2.flex_value_set_id=(select ffvs.flex_value_set_id from fnd_flex_value_sets ffvs where ffvs.flex_value_set_name=:flex_value_set_name)
) ffvnh,
fnd_flex_values_vl ffvv
where
3=3 and
ffvnh.parent_flex_value=ffvv.flex_value and
ffvnh.flex_value_set_id=ffvv.flex_value_set_id
connect by nocycle
ffvnh.parent_flex_value between prior ffvnh.child_flex_value_low and prior ffvnh.child_flex_value_high and
decode(nvl(prior ffvnh.range_attribute,'P'),'P','Y','N')=ffvv.summary_flag
start with
ffvnh.parent_flex_value=:parent_flex_value and
1=1 and
(:parent_flex_value is not null or
not exists (select null from
fnd_flex_value_norm_hierarchy ffvnh0
where
ffvnh0.flex_value_set_id=(select ffvs.flex_value_set_id from fnd_flex_value_sets ffvs where ffvs.flex_value_set_name=:flex_value_set_name) and
ffvnh.parent_flex_value between ffvnh0.child_flex_value_low and ffvnh0.child_flex_value_high and
ffvv.summary_flag=decode(ffvnh0.range_attribute,'P','Y','N')
)
)

要查看所有层次结构(不同的父级顶值),请删除对父级FLEX值的‘Start With’限制:

ffvnh.parent_flex_value=:parent_flex_value

相关问题