오라클 10.2 이상한 행동. 아니면 나야
-
20-09-2019 - |
문제
다음 쿼리를 확인하십시오. SQL은 외모만큼 나쁘지 않습니다. 기본적으로 사실 테이블이 있고 일부 차원 테이블에 간단한 조인이 있습니다. 그런 다음 별명 계정 DIM-DEP를 고려할 때 파생 테이블에 가입합니다.
SELECT dw_mgr.fa_trans_fct.period,
dw_mgr.fa_trans_fct.asset_cost_company_code,
dw_mgr.fa_trans_fct.asset_cost_center_id,
dw_mgr.fa_trans_fct.depreciation_account_id,
accounts_dim_dep.description,
dw_mgr.projects_dim.project_num,
dw_mgr.projects_dim.project_name,
ROUND (dw_mgr.fa_trans_fct.activity_deprn_amount_us, 2),
organizations_cost.major_geography,
organizations_cost.business_unit || organizations_cost.bu_desc,
organizations_cost.industry_sector_num
||organizations_cost.industry_sector_desc,
hyperion_organizations.hyperion_num,
hyperion_organizations.hyperion_desc,
hyperion_organizations.hyperion_reporting
FROM dw_mgr.fa_trans_fct,
(SELECT DISTINCT flex_value account_id, description
FROM rf_fnd_flex_values_det
WHERE flex_value_set_id = '1002363'
AND summary_flag = 'N') accounts_dim_dep,
dw_mgr.projects_dim,
dw_mgr.organizations organizations_cost,
dw_mgr.organizations hyperion_organizations
WHERE
--Fact to Org on Company Code / Cost Center
(dw_mgr.fa_trans_fct.asset_cost_center_id
= organizations_cost.cost_center_id)
AND (dw_mgr.fa_trans_fct.asset_cost_company_code
= organizations_cost.company_code)
--Fact to Projects Dim on Proj Num
AND (dw_mgr.projects_dim.project_num = dw_mgr.fa_trans_fct.project_num)
--Fact to Accounts_Dim_Dep on Account ID
--convert account_ID on left to_number??????
AND (accounts_dim_dep.account_id
= dw_mgr.fa_trans_fct.depreciation_account_id)
--Fact Hyp Company Code Cost Center to Hyp Org
AND (hyperion_organizations.cost_center_id
= dw_mgr.fa_trans_fct.asset_cost_center_id AND
hyperion_organizations.company_code
= dw_mgr.fa_trans_fct.asset_cost_company_code)
--Filters
AND (
dw_mgr.fa_trans_fct.period IN ('01-Jun-2009')
--works
--AND dw_mgr.fa_trans_fct.asset_cost_center_id IN ('000296')
--does not work
AND dw_mgr.fa_trans_fct.asset_cost_center_id IN ('000296','000296')
AND dw_mgr.fa_trans_fct.asset_cost_company_code = '0007'
)
------------------------------------------------------------
Statement Id=4203172 Type=
Cost=2.64018716311899E-308 TimeStamp=06-10-09::17::51:43
(1) SELECT STATEMENT CHOOSE
Est. Rows: 1 Cost: 6
(14) NESTED LOOPS
Est. Rows: 1 Cost: 6
(11) NESTED LOOPS
Est. Rows: 1 Cost: 5
(9) HASH JOIN
Est. Rows: 1 Cost: 3
(3) TABLE TABLE ACCESS BY INDEX ROWID DW_MGR.ORGANIZATIONS [Analyzed]
(3) Blocks: 1,669 Est. Rows: 1 of 31,748 Cost: 1
Tablespace: DIM_DATA
(2) INDEX (UNIQUE) INDEX UNIQUE SCAN DW_MGR.ORG_PK [Analyzed]
Est. Rows: 1 Cost: 1
(8) PARTITION RANGE SINGLE
Est. Rows: 7 Cost: 1
(7) PARTITION LIST ALL
Est. Rows: 7 Cost: 1
(6) TABLE TABLE ACCESS BY LOCAL INDEX ROWID DW_MGR.FA_TRANS_FCT [Analyzed]
Blocks: 1,431,026 Est. Rows: 7 of 32,900,663 Cost: 1
(5) BITMAP CONVERSION TO ROWIDS
(4) INDEX (BITMAP) BITMAP INDEX SINGLE VALUE DW_MGR.FA_TRANS_AST_COMP_CC_BM_I
(10) REMOTE REMOTE.RF_FND_FLEX_VALUES_DET
Est. Rows: 1 Cost: 2
(13) TABLE TABLE ACCESS BY INDEX ROWID DW_MGR.PROJECTS_DIM [Analyzed]
(13) Blocks: 12,184 Est. Rows: 1 of 163,117 Cost: 1
Tablespace: PROJECT_DATA
(12) INDEX (UNIQUE) INDEX UNIQUE SCAN DW_MGR.PROJECTS_UI [Analyzed]
Est. Rows: 1 Cost: 1
사용자는 자신의 Webi (Business Intelligence) 보고서가 필터에 여러 비용 센터를 포함시켜 "In"을 포함하는 SQL이 여러 값을 포함하여 다음 오류를 반환했다고 불평했습니다.
[1]: (Error): ORA-01722: invalid number ORA-02063: preceding line from [dbname]
그렇지 않으면 단일 비용 센터의 경우 보고서가 제대로 작동했습니다. 흥미로운 부분은 다음과 같은 조건이 나타나는 것을 알았습니다. 관련이 없습니다, SQL에 부정적인 영향을 미쳤습니다.
accounts_dim_dep.account_id = dw_mgr.fa_trans_fct.depreciation_account_id
여기서 문제는 왼쪽의 열, accounts_dim_dep.account_id 열이 db에 Charch a, 오른쪽의 col, dw_mgr.fa_trans_fct.depreciation_account_id가 숫자로 정의된다는 것입니다.
숫자를 바르 차로 변환하기 위해 조인 조건을 수정했을 때 ...
accounts_dim_dep.account_id
= to_char(dw_mgr.fa_trans_fct.depreciation_account_id)
... SQL은 필터에 지정된 비용 센터 수에 관계없이 작동합니다.
겉보기에 관련이없는 열의 유형 불일치가 IN 목록에 여러 비용 센터를 지정할 수 있는지 여부에 어떤 영향을 미치는지 알고 싶습니다.
해결책
PLW 오류가 활성화 된 경우 이전 상황에 대해 경고했을 것입니다. 나는 당신의 쿼리를 다시 작성합니다.
SELECT t.period,
t.asset_cost_company_code,
t.asset_cost_center_id,
t.depreciation_account_id,
add.description,
pd.project_num,
pd.project_name,
ROUND(t.activity_deprn_amount_us, 2),
o.major_geography,
o.business_unit || o.bu_desc,
o.industry_sector_num || o.industry_sector_desc,
o.hyperion_num,
o.hyperion_desc,
o.hyperion_reporting
FROM DW_MGR.FA_TRANS_FCT t
JOIN DW_MGR.PROJECTS_DIM pd ON pd.project_num = t.project_num
JOIN DW_MGR.ORGANIZATIONS o ON o.cost_center_id = t.asset_cost_center_id
AND o.company_code = t.asset_cost_company_code
JOIN (SELECT TO_NUMBER(rffvd.flex_value) 'account_id',
rffvd.description
FROM RF_FND_FLEX_VALUES_DET rffvd
WHERE rffvd.flex_value_set_id = '1002363'
AND rffvd.summary_flag = 'N'
GROUP BY rffvd.flex_value,
rffvd.description) add ON add.account_id = t.depreciation_account_id
WHERE t.period IN ('01-Jun-2009')
AND t.asset_cost_center_id IN ('000296','000296') --doesn't work
AND t.asset_cost_company_code = '0007'
변경 로그:
- 테이블 별명을 사용하여 타이핑을 저장하십시오 (또한 다른 사람들이 읽고 도와 줄 수 있습니다)
- 제거 : Hyperion_organization은 동일한 기준을 사용하여 동일한 테이블에 가입했습니다.
- 지정되었습니다
TO_NUMBER(RF_FND_FLEX_VALUES_DET.flex_value)
따라서 전환은 가입 전에 발생합니다
ORA 오류가 IN 절의 2 개 이상의 항목에서 발생하는 이유는 모르겠지만 게시 한 것과 동일하게 두 가지를 제공 한 다음 데이터 문제가 될 가능성이 없습니다.
다른 팁
ORA-02063 오류는 ORA-01722 오류가 원격 데이터베이스에서 발생 함을 의미합니다. 이는 (설명 계획에 따라) RF_FND_FLEX_VALUES_DET 테이블이 원격이라는 사실에 맞습니다.
가치 accounts_dim_dep.account_id
a flex_value
, Varchar2 인 것으로 보이며 거의 확실히 비수체 값을 포함합니다. 숫자 열과 비교할 때 Oracle은 암시 적을 적용합니다. TO_NUMBER()
숫자가 아닌 값에 부딪 치면 ORA-01722로 실패합니다. 변환하여dw_mgr.fa_trans_fct.depreciation_account_id
문자열에는 암시 적 변환을 피합니다.
그렇다면 왜 원래 쿼리가 하나의 비용 센터 만 있지만 여러 가지가있을 때 실패 할 때 왜 원래 쿼리가 성공합니까? 데이터에 액세스하여 일부 테스트를 실행하거나 최소한 다른 버전에 대한 설명 계획을 수행하지 않으면 확실하지 않습니다. 그러나 당신이 게시 한 설명 계획은 원격 작업이 RF_FND_FLEX_VALUES_DET에서 한 행을 검색한다는 것을 보여줍니다. 여러 비용 센터로 쿼리를 실행할 때 일부는 주먹을 뽑는 것입니다. flex_value
숫자가 아닌 값이 있습니다.