2011-05-23 61 views
0

我在6個月前的ASP.net web應用程序中開始使用DataSet。這是一個漂亮的工具,允許我快速開發MVC應用程序,而無需在數據庫連接/查詢中完成所有骯髒的工作。當查詢有效時,ASP.NET DataAdapter查詢無效

但今天我遇到了一些奇怪的問題。它開始與此查詢:

select a.MR_PART_CODE as PART_CODE,

 b.PART_DESC as PART_DESC, 
     b.PM_MAD_CAT_CODE as CATEGORY, 
     c.MPC_MIN_QTY as CAT_SS, 
     a.MR_MAX_LEAD_TIME as LEAD_TIME, 
     a.MR_MAD as MAD, 
     ROUND((a.MR_MAD * a.MR_MAX_LEAD_TIME)) as CAL_SS, 
     greatest(ROUND((a.MR_MAD * a.MR_MAX_LEAD_TIME)),c.MPC_MIN_QTY) as SS, 
     d.SOH as SOH, 
     d.SOO as SOO, 
     (select sum(back_order) from STK_REQUEST where part_code=b.part_code) as BO, 
     (d.SOH+a.MR_SOO) as AVAIL, 
     ((d.SOH + a.MR_SOO)-greatest(ROUND((a.MR_MAD * a.MR_MAX_LEAD_TIME)),c.MPC_MIN_QTY)) as ROQ, 
     (d.SOH - greatest(ROUND((a.MR_MAD * a.MR_MAX_LEAD_TIME)),c.MPC_MIN_QTY)) as VAR, 
     a.MR_REMARKS as REMARKS   
    from ROQ a, PART_MASTER b, MAD_PARTS_CATEGORY c, PART_STATS d 
    where a.MR_PART_CODE = b.PART_CODE 
    and d.PART_CODE = b.PART_CODE 
    and b.PM_MAD_CAT_CODE = c.MPC_CAT_CODE 
    and b.RETIRE_FLAG = 'N' 
    and a.mr_year = (select max(mr_year) from roq) 
    and a.mr_month = (select max(mr_month) from roq where mr_year= (select max(mr_year) from roq)) 
    and a.mr_period = (select max(mr_period) from roq where mr_month=(select max(mr_month) from roq where mr_year= (select max(mr_year) from roq)) and mr_year= (select max(mr_year) from roq)) 
    and  greatest(ROUND((a.MR_MAD * a.MR_MAX_LEAD_TIME)),c.MPC_MIN_QTY) > d.SOH` 

查詢蟾蜍跑細了甲骨文,但顯然它,當我試圖安裝在DataAdapter對象一個新的查詢失敗。它說這樣的行:「函數參數列表中的錯誤:SELECT not recognized」: (select sum(back_order) from STK_REQUEST where part_code=b.part_code) as BO

我做錯了什麼?

僅供參考,數據庫是Oracle。

回答

0

這似乎是一些嘗試解析SQL的ASP類的例外。如果消息來自Oracle,將會有一個ORA-xxxxx錯誤號。

你不應該把這樣的SQL放在ASP中。相反,創建一個視圖,也許它沒問題。

+0

感謝您的建議。你介意更多的解釋爲什麼在asp.net數據適配器中使用View而不是普通的SQL? – 2011-05-24 02:23:33