0

我尝试调用我的 oracle 函数,但由于某种原因,我得到了奇怪的结果。

这是我的 C# 代码:

using (OracleConnection _conn = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.20.190.2)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=DBIDB)));User Id=blng;Password=blng;"))
{
    using (OracleCommand cmd = new OracleCommand())
    {
        _conn.Open();

        cmd.Connection = _conn;
        cmd.CommandType = System.Data.CommandType.StoredProcedure;

        cmd.CommandText = "PKG_update_switch.checkexistsinswitch";
        cmd.Parameters.Add("phone", OracleDbType.Varchar2, ParameterDirection.Input).Value = phoneToQuery;
        cmd.Parameters.Add("res", OracleDbType.Int32, ParameterDirection.ReturnValue);
        cmd.ExecuteNonQuery();

        result = cmd.Parameters["res"].Value.ToString();
        Debug.WriteLine("---" + result);

        if (result.Equals("null"))
            message = "Didnt find number";
        else
            message = "Found " + phoneToQuery + " in " + result;
        MessageBox.Show(message, "Check Phone Exists",
        MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
        _conn.Close();
    }
}

结果我总是得到0,女巫是不可能的。

甲骨文功能:

function checkExistsInSwitch(phone in varchar2) RETURN integer is
  tmp varchar2(100):='';
  begin
    for t in (select c.re_collection_id from re_collection_values c where c.start_range = phone)
        loop
         ----- check that the number is from folder number 2
         begin
        select o.network_identifier into tmp from operators o where o.switch_folder_id = t.re_collection_id;
        return 11;--tmp;
      exception 
        when others then
          null;
      end;
    end loop;
return 11;--'';
end;

这很奇怪,对于存储过程,我得到了很好的结果,这只发生在我的存储函数身上。

4

0 回答 0