用作子查询时的分层查询给出:ORA-00911:无效字符
Posted
技术标签:
【中文标题】用作子查询时的分层查询给出:ORA-00911:无效字符【英文标题】:Hierarchical query when used as sub query gives : ORA-00911: invalid character 【发布时间】:2013-03-04 09:06:02 【问题描述】:我一直在尝试执行以下查询,并引发以下错误:
ORA-00911:无效字符
select
sum(coalesce(decode(FKTD_DR_CR_TYPE,'1',FKTD_NRS_AMOUNT,0),0)) as DEBIT_AMOUNT,
sum(coalesce(decode(FKTD_DR_CR_TYPE,'0',FKTD_NRS_AMOUNT,0),0)) as CREDIT_AMOUNT
from FMS_KS_TRANS_DTL
inner join FMS_KS_TRANS_MST
ON FMS_KS_TRANS_MST.FKTM_TRANS_MST_ID = FMS_KS_TRANS_DTL.FKTD_TRANS_MST_ID
inner join FMS_FC_VOUCHER_CONFIG
ON FMS_FC_VOUCHER_CONFIG.FFVC_VOUCHER_ID = FMS_KS_TRANS_MST.FKTM_VOUCHER_ID
where FFVC_ACCOUNT_TYPE = 5 and FKTM_FISCAL_YEAR='2066/67'
and FKTD_ACC_ID in
(
select FFAM_ACC_ID from FMS_FC_ACC_MST
where ffam_group_flag = 2 and FFAM_FISCAL_YEAR='2066/67'
start with ffam_acc_id in
(
select distinct FKP_CASH_ACC_ID from FMS_KS_PARAMETER
where FKP_FISCAL_YEAR='2066/67'
)
connect by ffam_group_flag = 2
and prior ffam_acc_id = ffam_upper_acc_id;
/*
This sub query executes fine if executed separately
and this whole query block executes fine if
this hierarchical query is not used.
*/
)
【问题讨论】:
我会说这很奇怪...... 我在;
字符上得到ORA-00907: missing right parenthesis
。
您可以添加create table语句,我们可以自己尝试。
@ÁlvaroG.Vicario 为什么他得到ORA-00911: invalid character
而不是ORA-00907: missing right parenthesis
?
删除分号对我有用,感谢您的努力和时间:)
【参考方案1】:
注释查询前的分号?
【讨论】:
【参考方案2】:子查询不应以 ;
结尾
select
sum(coalesce(decode(FKTD_DR_CR_TYPE,'1',FKTD_NRS_AMOUNT,0),0)) as DEBIT_AMOUNT,
sum(coalesce(decode(FKTD_DR_CR_TYPE,'0',FKTD_NRS_AMOUNT,0),0)) as CREDIT_AMOUNT
from FMS_KS_TRANS_DTL
inner join FMS_KS_TRANS_MST
ON FMS_KS_TRANS_MST.FKTM_TRANS_MST_ID = FMS_KS_TRANS_DTL.FKTD_TRANS_MST_ID
inner join FMS_FC_VOUCHER_CONFIG
ON FMS_FC_VOUCHER_CONFIG.FFVC_VOUCHER_ID = FMS_KS_TRANS_MST.FKTM_VOUCHER_ID
where FFVC_ACCOUNT_TYPE = 5 and FKTM_FISCAL_YEAR='2066/67'
and FKTD_ACC_ID in
(
select FFAM_ACC_ID from FMS_FC_ACC_MST
where ffam_group_flag = 2 and FFAM_FISCAL_YEAR='2066/67'
start with ffam_acc_id in
(
select distinct FKP_CASH_ACC_ID from FMS_KS_PARAMETER
where FKP_FISCAL_YEAR='2066/67'
)
connect by ffam_group_flag = 2
and prior ffam_acc_id = ffam_upper_acc_id
);
我想应该可以工作(分号移动),除非还有其他错误:-)
【讨论】:
以上是关于用作子查询时的分层查询给出:ORA-00911:无效字符的主要内容,如果未能解决你的问题,请参考以下文章
数据库查询语句报错-ORA-00911: invalid character
ORA-00911: 无效字符 00911. 00000 - Oracle 中出现“无效字符”异常错误