Iftikhar Ali Ansari
Iftikhar Ali Ansari

Reputation: 1760

Unable to get boolean value from oracle stored procedure

I am trying from hours to find out how I can get the returned value as boolean from oracle stored procedure.

I created a simple SP which is returning a boolean as out but when I pass the parameter as OracleDbType.Boolean I am getting error.

This is my sp

create or replace procedure nbq_out_test (pi_bool_in IN BOOLEAN,
                                  pi_var_in  IN VARCHAR2,
                                  pi_num_in  IN NUMBER,
                                  po_bool_out OUT BOOLEAN,
                                  po_var_out  OUT VARCHAR2,
                                  po_num_out OUT NUMBER) AS
BEGIN
    po_bool_out := pi_bool_in ;
    po_var_out := pi_var_in;
    po_num_out := pi_num_in;

END   nbq_out_test;

And this is my c# code

OracleCommand command = new OracleCommand("NBQ_OUT_TEST", con);
            OracleParameter param;
            command.BindByName = false;
            command.CommandType = CommandType.StoredProcedure;

param = new OracleParameter("PI_BOOL_IN", OracleDbType.Boolean, ParameterDirection.Input); //Works fine as input
            param.Value = true;
            command.Parameters.Add(param);

param = new OracleParameter("PO_BOOL_OUT",OracleDbType.Boolean,ParameterDirection.Output); //This is the line causing error.

            command.Parameters.Add(param);
command.ExecuteNonQuery();

This is the error

ORA-06502: PL/SQL: numeric or value error\nORA-06512: at line 1

I cannot modify the Stored Procedure to return 1 or 0 or anything similar.

The oracle version is 12.1.0.2.0

The Oracle.ManagedDataAccess.18.3.0

I have searched lot but most of the suggestion was to modify the SP which is not at my end.

Any suggestion will be great help.

Upvotes: 1

Views: 1394

Answers (1)

ChipLimo
ChipLimo

Reputation: 71

OracleDbType doesn't seem to support Boolean.

I think your question already has an answer in below page. Boolean in OracleDbType

Upvotes: 1

Related Questions