2011-10-07 81 views
13

當我使用我的C#代碼運行pl/sql查詢[通過存儲過程]時,出現錯誤: 如何解決相同的問題?請指教。 注意:我在代碼中傳遞了providerSpecificTypes的false。當執行pl/sql查詢時出現溢出錯誤

Error Message: 
System.Data.OracleClient.OracleException: OCI-22053: overflow error 
at System.Data.Common.DbDataAdapter.FillErrorHandler(Exception e, DataTable dataTable, Object[] dataValues)  
at System.Data.Common.DbDataAdapter.FillLoadDataRowChunk(SchemaMapping mapping, Int32 startRecord, Int32 maxRecords)  
at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)  
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) 
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)  
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, 

下面是代碼:

DataSet ds = new DataSet(); 
     try 
     { 
      this.OpenDBConnection(); 
      this.dbAdapter.ReturnProviderSpecificTypes = providerSpecificTypes; 
      this.dbAdapter.Fill(ds); 
     } 
     catch 
     { 
      throw; 
     } 
     finally 
     { 
      CloseDBConnection(); 
      this.cmd.Parameters.Clear(); 
     } 
      return ds; 

查詢:

SELECT client_id, TO_CHAR (business_dt, 'MM/DD/YYYY') AS business_dt 
     , mkt_type 
     , mkt_name 
     , product_name 
     , period 
     , TO_CHAR (start_dt, 'MM/DD/YYYY') AS start_dt 
     , TO_CHAR (end_dt, 'MM/DD/YYYY') AS end_dt 
     , duration 
     , term 
     , NULL AS strike_price 
     , instrument_type 
     , final_price 
     , NULL AS product_price 
     , units 
     , NULL AS expiry_dt 
     , mkt_close 
     , cons_flag 
+1

請添加查詢的其餘部分。列的數據類型也不錯 –

+0

什麼數據庫版本?什麼是數據類型?確保您將Date或DateTime變量傳遞到您的TO_CHAR函數中... – manzwebdesigns

+0

數據庫是Oracle 10g.Yes,正在將DateTime變量傳遞到to_char函數。謝謝。 – user74042

回答

27

一個選定列值的由具有精度超出NET的小數類型。解決此問題的最佳方法是將列值循環到可管理的預置大小。通常我將它們四捨五入爲小數點後兩位數,因爲我不再需要它了,您可以根據自己的需要進行選擇。

因此,在短期,改變你的查詢,以便以更高的精度數都列四捨五入到您所需要的小數位數:

例子:

Select ROUND(final_price, 2) From <your table> 

應該解決您的問題。