如何删除此错误

时间:2017-02-16 10:39:42

标签: sql oracle

select sum((
SELECT 
SUM (gb.period_net_dr - gb.period_net_cr) "PTD" 
FROM gl_balances gb, gl_code_combinations gcc 
WHERE 
    gb.period_name = NVL(:P_PERIOD,gb.period_name)
AND gb.currency_code = (SELECT currency_code FROM gl_ledgers WHERE ledger_id = gb.ledger_id) 
AND gcc.segment4 =(select FLEX_VALUE from FND_FLEX_VALUES_VL where description ='Pass Through Costs To Be Realised')
AND gb.code_combination_id = gcc.code_combination_id) 
+
(SELECT 
SUM (gb.period_net_dr - gb.period_net_cr) "PTD" 
FROM gl_balances gb, gl_code_combinations gcc 
WHERE 
    gb.period_name = NVL(:P_PERIOD,gb.period_name)
AND gb.currency_code = (SELECT currency_code FROM gl_ledgers WHERE ledger_id = gb.ledger_id) 
AND gcc.segment4 =(select FLEX_VALUE from FND_FLEX_VALUES_VL where description ='Pass Through Costs Realised')
AND gb.code_combination_id = gcc.code_combination_id)) as Total_Pass_Through_Costs
from
dual)
(select sum((
SELECT 
SUM (gb.period_net_dr - gb.period_net_cr) "PTD" 
FROM gl_balances gb, gl_code_combinations gcc 
WHERE 
    gb.period_name = NVL(:P_PERIOD,gb.period_name)
AND gb.currency_code = (SELECT currency_code FROM gl_ledgers WHERE ledger_id = gb.ledger_id) 
AND gcc.segment4 =(select FLEX_VALUE from FND_FLEX_VALUES_VL where description ='Services Billing')
AND gb.code_combination_id = gcc.code_combination_id) 
+
(SELECT 
SUM (gb.period_net_dr - gb.period_net_cr) "PTD" 
FROM gl_balances gb, gl_code_combinations gcc 
WHERE 
    gb.period_name = NVL(:P_PERIOD,gb.period_name)
AND gb.currency_code = (SELECT currency_code FROM gl_ledgers WHERE ledger_id = gb.ledger_id) 
AND gcc.segment4 =(select FLEX_VALUE from FND_FLEX_VALUES_VL where description ='pass Through Billing')
AND gb.code_combination_id = gcc.code_combination_id)) as Total_Billing
from
dual

如何删除此错误 (java.sql.SQLSyntaxErrorException:ORA-00933:SQL命令未正确结束)

2 个答案:

答案 0 :(得分:0)

有2个没有配对的座位:

  • 1st不在任何地方打开
  • 第二个没有在任何地方关闭

你可以从字符串中检查一下那些:

...
from
dual)
(select sum...

它们似乎没有在任何地方打开/关闭。

答案 1 :(得分:0)

修复查询中的实际错误,不会让其他人搜索答案对此有用。

但是,找到此类问题的一些(明显的)提示可能会有用。

所以。 。 。

  • 将您的查询编辑成结构合理的内容(问题有时会突然冒出来)
  • 适当地缩进并将子查询的括号放在单独的行上并垂直排列。
  • 使用突出显示匹配括号的编辑器

修复此类错误是编码人员几乎可以为任何语言学习的基本技能。