2016-08-25 34 views
1

什么是Oracle等价于布尔值?我有这个函数,我需要将onlineFiling作为bool传递给存储过程,但显然Oracle的OracleDbType中没有布尔值。我该怎么做呢?谢谢OracleDbType中的布尔值

public List<MModel> GetReportData(DateTime startDateTime, DateTime endDateTime, bool onlineFiling) 
     { 
      var managementModel = new List<ManagementModel>(); 
      var oracCmd = new OracCommand(1); 
      oracCmd.AddInParameter(OracleDbType.Date, "I_STARTDATE", startDateTime)); 
      oracCmd.AddInParameter(OracleDbType.Date, "I_ENDDATE", endDateTime)); 
      oracCmd.AddInParameter(OracleDbType.???, "I_ONLINE", onlineFiling)); 
//rest of code here 
+0

你必须要么改变你的功能规格,接受字符或数字标志代替;或添加一个将字符/数字转换为布尔值的包装函数,并调用您的原始函数。 [没有本地类型](https://docs.oracle.com/cd/B19306_01/win.102/b14307/OracleDbTypeEnumerationType.htm),即使您不是调用PL/SQL [SQL](http:/ /stackoverflow.com/q/3726758/266304)。 –

回答

0

它取决于您调用的存储过程,但它通常使用二进制类型的ORACLE参数。

public List<MModel> GetReportData(DateTime startDateTime, DateTime endDateTime, bool onlineFiling) 
{ 
    var managementModel = new List<ManagementModel>(); 

    var oracCmd = new OracCommand(1); 
    oracCmd.AddInParameter(OracleDbType.Date, "I_STARTDATE", startDateTime)); 
    oracCmd.AddInParameter(OracleDbType.Date, "I_ENDDATE", endDateTime)); 
    oracCmd.AddInParameter(OracleDbType.BinaryDouble, "I_ONLINE", onlineFiling)); 

    //rest of code here 

但是你必须确定哪种类型被返回并将结果转换为正确的类型。