我正在尝试从.net核心运行存储过程,这给了我一个错误:
PostgresException:42703:关系“ AcceptanceActLines”的列“ AcceptanceActID”不存在
这是我正在尝试运行的查询:
create or replace function "ClosePeriod"(month integer, year integer)
returns void
language plpgsql
as
$$
DECLARE
BEGIN
INSERT INTO billing."AcceptanceActs"("AccountID", "Month", "Year","Amount")
SELECT
DISTINCT th."AccountID",
"month",
"year",
th."TotalAmount"
FROM billing."TransactionHeaders" AS th
WHERE th."AcceptanceActID" IS NULL;
UPDATE billing."TransactionHeaders" set "AcceptanceActID" = acc."ID" from
billing."AcceptanceActs" acc
where acc."Year"="year" AND acc."Month"="month" AND
acc."AccountID"=billing."TransactionHeaders"."AccountID"
AND billing."TransactionHeaders"."AcceptanceActID" is null;
INSERT INTO billing."AcceptanceActLines"("PackageId","Amount","AcceptanceActID")
SELECT
tl."PackageID",
SUM(tl."Amount"),
aa."ID"
FROM billing."TransactionHeaders" AS th
INNER JOIN billing."TransactionLines" AS tl ON th."Id" = tl."TransactionHeaderID"
INNER JOIN billing."AcceptanceActs" as aa ON th."AcceptanceActID" =
aa."ID"
WHERE aa."Month"=="month" AND aa."Year"=="year"
GROUP BY tl."PackageID", aa."ID";
END;
$$;
alter function "ClosePeriod"(integer, integer) owner to postgres;
我在互联网上看到了类似的问题,无法解决我的问题。