使用CASE创建TableAdapter

时间:2017-03-28 03:15:57

标签: sql oracle visual-studio-2015 case tableadapter

我尝试在数据集设计器中创建TableAdapter(Visual Studio 2015 C#WinApp with Oracle Database)

这是我的代码

SELECT concat(concat(G.ACCOUNT_CODE,'-'),G.SUB_ACCOUNT_CODE) as account_code 
,SU.ACCOUNT_DESCRIPTION 
,sum(case when G.VOUCHER_DATE <= :fiscal_year then (case when G.AMOUNT<0 then abs(G.AMOUNT) else -(G.AMOUNT) end) else 0 end) as opening_balance          
,sum(case when G.VOUCHER_DATE > :fiscal_year then (case when G.AMOUNT<0 then abs(G.AMOUNT) else -(G.AMOUNT) end) else 0 end) as current_period 
,sum((case when G.AMOUNT<0 then abs(G.AMOUNT) else -(G.AMOUNT) end)) closing_balance 
FROM GL_POSTING_DETAILS G,SUB_ACCOUNT_MASTERS SU 
WHERE EXISTS(SELECT '1' 
               FROM PROJECTS 
               WHERE  G.COMPANY   = PROJECTS.COMPANY
               AND    G.PROJECT   = PROJECTS.PROJECT 
               AND  PROJECTS.STATUS = 'A')   
AND G.STATUS != 'Z' 
AND G.voucher_type != 'CL' 
AND G.ACCOUNT_CODE = SU.ACCOUNT_CODE 
AND G.SUB_ACCOUNT_CODE = SU.SUB_ACCOUNT_CODE 
AND G.COMPANY = SU.COMPANY 
AND G.company like :company 
AND G.project like :project 
AND G.department_code like :department 
AND G.VOUCHER_DATE BETWEEN :from_date AND :to_date 
GROUP BY GROUPING SETS ((concat(concat(G.ACCOUNT_CODE,'-'),G.SUB_ACCOUNT_CODE),SU.ACCOUNT_DESCRIPTION),()) 
ORDER BY concat(concat(G.ACCOUNT_CODE,'-'),G.SUB_ACCOUNT_CODE)

此代码在Toad中运行良好但不适用于数据集设计器

Error in list of function argument: 'then' not recognized

Error in list of function argument: ')' not recognized

Unable to parse query text

提前谢谢

0 个答案:

没有答案