简体   繁体   English

PostgresException:42883:尝试调用过程时,函数X(没有时区的时间戳)不存在

[英]PostgresException: 42883: function X(timestamp without time zone) does not exist when trying to call procedure

I am trying to call stored procedure using .net core. 我试图使用.net核心调用存储过程。

I had This problem. 我有这个问题。 After fixing my previous problem, I have another syntax error. 修复我以前的问题后,我有另一个语法错误。

PostgresException: 42883: function GetActiveUserPackagesForOpenBillingPeriod(timestamp without time zone) does not exist when trying to call procedure PostgresException:42883:函数GetActiveUserPackagesForOpenBillingPeriod(没有时区的时间戳)在尝试调用过程时不存在

This is the code: 这是代码:

        var date = DateTime.Now;
        List<ActivePackageForOpenBillingPeriod> activeUserPackagesForOpenBillingPeriod = null;

        using (var conn = new NpgsqlConnection ("Host=localhost;Port=xxx;Database=postgres;Username=postgres;Password=xxx;TrustServerCertificate=true;ApplicationName=xxx;")) 
        {                
            var s = "Select * FROM \"GetActiveUserPackagesForOpenBillingPeriod\"({0})";
            activeUserPackagesForOpenBillingPeriod = context.ActivePackageForOpenBillingPeriods.FromSql (s, date).ToList ();

        }

Stored Procedure 存储过程

create or replace function "GetActiveUserPackagesForOpenBillingPeriod"(somedate timestamp without time zone) returns TABLE("Amount" numeric, "Package" integer, "User" integer, "Account" integer, "AcceptanceActID" integer, "HasChangedPackage" boolean)
language plpgsql
as
$$
DECLARE
    BEGIN
      RETURN QUERY
        SELECT
            up."TotalAmount",
            up."PackageID",
            u."ID" AS "UserId",
            a."ID" AS "AccountId",
            th."AcceptanceActID",


            CASE
                  WHEN count(DISTINCT tl."PackageID") IN (0,1)  THEN false
                  ELSE true
            END AS "HasChangedPackage"

        FROM public."Accounts" as a
            LEFT JOIN billing."TransactionHeaders" AS th ON th."AccountID" = a."ID"
            INNER JOIN security."Users" AS u ON u."AccountID"= a."ID"
            INNER JOIN billing."UserPackages" AS up ON up."UserID"=u."ID" AND COALESCE(th."Date", date) BETWEEN up."StartDate" AND COALESCE(up."EndDate", date)
            LEFT JOIN billing."TransactionLines" AS tl ON th."Id" = tl."TransactionHeaderID"

        WHERE th."AcceptanceActID" IS NULL AND a."StatusID"!=4 AND a."StatusID"!=3 AND up."StatusID"=1


        GROUP BY a."ID", u."ID", up."PackageID", 
up."TotalAmount",th."AcceptanceActID";
RETURN;

END;
$$;

alter function "GetActiveUserPackagesForOpenBillingPeriod"(timestamp)  
owner 
to postgres;

Class

public class ActivePackageForOpenBillingPeriod {
    public int Id { get; set; }

    public int AccountID { get; set; }

    [ForeignKey ("AccountID")]
    public Account Account { get; set; }
    public int UserID { get; set; }

    [ForeignKey ("UserID")]
    public User User { get; set; }
    public int PackageID { get; set; }

    [ForeignKey ("PackageID")]
    public Package Package { get; set; }
    public decimal TotalAmount { get; set; }
    public bool HasChangedPackage { get; set; }

}

Don't use timestamp parameter, you must use the varchar parameter. 不要使用timestamp参数,必须使用varchar参数。 And in the stored procedure you change the type varchar for the timestamp. 在存储过程中,您可以更改时间戳的类型varchar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PostgreSQL:42883 运算符不存在:没有时区的时间戳 = 文本 - PostgreSQL: 42883 Operator does not exist: timestamp without time zone = text PostgreSQL:42883运算符不存在:没有时区的时间戳 - PostgreSQL: 42883 Operator does not exist: timestamp without time zone PostgresException:42883:运算符不存在:@字符变化 - PostgresException: 42883: operator does not exist: @ character varying Npgsql.PostgresException (0x80004005): 42883: 运算符不存在: jsonb #&gt; text - Npgsql.PostgresException (0x80004005): 42883: operator does not exist: jsonb #> text 运算符不存在:@timestamp without time zone - operator does not exist: @ timestamp without time zone 从 C# 调用时,Npgsql.Postgresql 异常 42883 function 不存在 - 是否有可用的工作示例? - Npgsql.Postgresql Exception 42883 function does not exist when called from C# - is there a working example available? Npgsql.PostgresException:关系“表名”不存在&#39; - Npgsql.PostgresException: relation "tablename" does not exist' 42883:函数不存在-在Entity Framework C#Npgsql中调用Postgres函数 - 42883: function does not exist - Calling Postgres Functions in Entity Framework C# Npgsql 运行存储过程时出现错误“光标X不存在” - Error “cursor X does not exist” when running a stored procedure 怎么说日期时间 - EF Core 6.0 中没有时区的时间戳 - How to say Datetime - timestamp without time zone in EF Core 6.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM