我正在将MS SQL Server存储过程转换为PostgresSQL中的存储函数。在这种情况下,需要使用合并将十进制值转换为isull,但是在这一行中,我遇到了语法错误。
StoredFunction:
CREATE OR REPLACE FUNCTION GetDeptListForViewModifyJointUsePercentages (
p_nInstID numeric,
p_nDeptID numeric) RETURNS VOID
AS $$
declare v_AccountTotal decimal(18,2);
BEGIN
select SUM(CONVERT(decimal(18,2), coalesce(eam.npayroll_amt, 0))) as AccountTotal
FROM
Account acct
INNER JOIN employeeaccountmapping eam
ON eam.nacct_id = acct.naccount_id
AND acct.ninst_id =p_nInstID
where acct.ndept_id =p_nDeptID
)
OutputPane:
ERROR: syntax error at or near ","
LINE 7: select SUM(CONVERT(decimal(18,2), coalesce(eam.npayroll_amt,...
^
答案 0 :(得分:1)
您可能想要类型转换:
CAST (coalesce(...) AS decimal(18,2))