1

what is Oracle equivalent for Boolean? I have this function where I need to pass onlineFiling to a stored procedure as bool but apparently Oracle don't have Boolean in its OracleDbType. How do I do this? thanks

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
amaach
  • 55
  • 1
  • 2
  • 6
  • You'll have to either change your function specification to accept a character or number flag instead; or add a wrapper function that translates a character/number to boolean and calls your original function. [There is no native type](https://docs.oracle.com/cd/B19306_01/win.102/b14307/OracleDbTypeEnumerationType.htm), even though you're calling PL/SQL not [SQL](http://stackoverflow.com/q/3726758/266304). – Alex Poole Aug 25 '16 at 18:38

2 Answers2

1

Look at the Oracle Data Provider documentation at Data Provider for .NET Developer's Guide. ODP does not seem to support boolean.

One option could be to use Char instead or Number with 1/0.

Also you should have a look at following SO posts:

"Boolean" parameter for Oracle stored procedure

How to pass boolean parameter to Oracle procedure C#

Community
  • 1
  • 1
STORM
  • 4,005
  • 11
  • 49
  • 98
0

It depends on the stored procedure that you are calling, but it's commonly used the Binary type of ORACLE parameters.

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

But you have to make sure which type is being returned and the convert the result to the right type.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459