Informix中的SQL查詢注意事項

string sql = "SELECT ms.m01_item_no,pm.cust_po_no, pm.order_date as chcode  FROM po_request_mast pm,po_request_detail pd,edi_cust ec,mcust mc,shipto sh,  outer mstock ms ,outer stdcost std  WHERE pm.order_cntl_no = pd.order_cntl_no AND pm.cu_bill_to = ec.customer_code  AND ec.customer_code = mc.m06_bill_to AND sh.d08_bill_to = mc.m06_bill_to  AND sh.d08_cust_ship = pm.cu_ship_to AND ec.co_code = mc.m06_co AND pd.ac_product_no = ms.m01_item_no AND pd.ac_product_no = std.std_stk_item  AND pm.check_flag = ? AND ms.m01_brand in ('Acer','eMachines') ORDER BY pm.cust_po_no";

 

 

        using (EdiOrderAuditMgr mgr = new EdiOrderAuditMgr(false))

        {

 

            //DataTable dtResult = mgr.GetData(sql);

 

            OdbcParameter[] oParams = new OdbcParameter[1];

            oParams[0] = new OdbcParameter("status", "W");

            //oParams[1] = new OdbcParameter("brand", "'Acer','eMachines'");

            //oParams[1] = new OdbcParameter("brand", "'eMachines'");

            DataTable dtResult = mgr.GetData(sql, oParams);

 

            gdvContent11.DataSource = dtResult;

            gdvContent11.DataBind();

        }

 

 

如上所示:

以條件ms.m01_brand in ('Acer','eMachines') 查詢沒有問題;

但如果採用OdbcParameter方式傳參,要注意:informix不支持 in

 

這個問題折磨了我大半天,總算找到原因了!

發佈了43 篇原創文章 · 獲贊 3 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章