【问题标题】:How can I figure out this Channel Destruct error? [closed]我怎样才能找出这个 Channel Destruct 错误? [关闭]
【发布时间】:2021-07-15 13:17:01
【问题描述】:

错误信息

Npgsql.PostgresException (0x80004005): 42883: function cdr.channeldestructed(_cdrid => integer) does not exist
   at Npgsql.NpgsqlConnector.<>c__DisplayClass159_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Npgsql.NpgsqlConnector.<>c__DisplayClass159_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Npgsql.NpgsqlDataReader.<NextResult>d__44.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Npgsql.NpgsqlDataReader.NextResult()
   at Npgsql.NpgsqlCommand.<ExecuteReaderAsync>d__101.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Npgsql.NpgsqlCommand.<ExecuteNonQuery>d__92.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Npgsql.NpgsqlCommand.ExecuteNonQuery()
   at PBXCommon.CDR.dbCDR.ChannelDestructed(Int32 CdrID) in C:\Users\fmurphy\source\repos\CDYNE PBX\PBXCore\PBXCommon\CDR\dbCDR.cs:line 183
   at PBXCore.Channels.Channel.Finalize() in C:\Users\fmurphy\source\repos\CDYNE PBX\PBXCore\PBXCore\Channels\Channel.cs:line 359
  Exception data:
    Severity: ERROR
    SqlState: 42883
    MessageText: function cdr.channeldestructed(_cdrid => integer) does not exist
    Hint: No function matches the given name and argument types. You might need to add explicit type casts.
    Position: 15
    File: parse_func.c
    Line: 624
    Routine: ParseFuncOrColumn

存在线路错误的代码

public static void ChannelDestructed(int CdrID)
        {
            using (NpgsqlConnection c = PBXCommon.dbCommon.GetNewPostgresConnection())
            {
                c.Open();
                NpgsqlCommand cmd = new NpgsqlCommand("cdr.channeldestructed", c);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add("_cdrid", NpgsqlDbType.Integer).Value = CdrID;
183             cmd.ExecuteNonQuery();
            }

        }



 ~Channel()
        {
            try
            {
                WeakReference oC;
                ChannelList.AllChannels.TryRemove(ChannelID, out oC);

359             PBXCommon.CDR.dbCDR.ChannelDestructed(CdrID);
            }
            catch (Exception ex)
            {

                PBXLogging.Log(LoggingLevel.Error, this, "Channel - Destruct Error\r\n{0}", ex);
            }

            PBXLogging.Log(LoggingLevel.Debug, this, "Channel - Destructed");

我是一名实习生,试图为我的老板解决这个问题,但我并没有编写大部分代码。这使用用 C# 编写的 PostgreSQL 进行数据库管理。

【问题讨论】:

  • "没有函数匹配给定的名称和参数类型。"听起来您尝试调用的存储过程不存在。你检查过它是否存在吗?
  • 是的,StoredProcedue = 4;另外,我刚刚找到了我老板放入的调试try catch。try { WeakReference oC; ChannelList.AllChannels.TryRemove(ChannelID, out oC); PBXCommon.CDR.dbCDR.ChannelDestructed(CdrID); } catch (Exception ex) { PBXLogging.Log(LoggingLevel.Error, this, "Channel - Destruct Error\r\n{0}", ex); } PBXLogging.Log(LoggingLevel.Debug, this, "Channel - Destructed");
  • 存储过程是在数据库服务器上定义的。听起来函数cdr.channeldestructed 在您的数据库中不可用。 StoredProcedue = 4 不是函数定义。要了解存储过程,这篇文章可能会有所帮助:carto.com/help/working-with-data/sql-stored-procedures
  • 感谢您的帮助!您是对的 - 该函数在我们的 Postgres 数据库中的名称不同,并且在我们切换时没有正确命名。
  • 太棒了。我已将其发布为答案,以便其他人可以看到该帖子已解决。

标签: c# database postgresql


【解决方案1】:

错误消息“没有函数匹配给定的名称和参数类型。”听起来您的数据库中没有存储过程cdr.channeldestructed

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 2021-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多