stored-procedures.net-coreoracle11gentity-framework-coreoutput-parameter

"numeric or value error" on the output parameter of EF CORE call to Oracle11g


I followed all the online help I could get and come up with this:

Stored Procedure:

create or replace procedure            proc_cmap_unit_test 
(
  param1 in varchar2
  ,tkn out varchar2
) as 
  begin
    select 'hello' into tkn from dual;
  null;
end proc_cmap_unit_test;

On .Net CORE, I have these:

OracleParameter param1 = new OracleParameter
  (
    "param1"
    , OracleDbType.Varchar2
    , ParameterDirection.Input
  );

OracleParameter token = new OracleParameter
  (
    "tkn"
    , OracleDbType.Varchar2
    , ParameterDirection.Output
  );

cntxt.Database
     .ExecuteSqlCommand($"BEGIN PROC_CMAP_UNIT_TeST(:param1, :tkn); end;", param1, token);

After I run the code, I got this stupid error:

ORA-06502: PL/SQL: numeric or value error

Can anyone tell me what am I missing? Thanks!


Solution

  • Problem solved:

    For some reason, I have to explicitly set the size of the output variable.

    token.Size = '10';