0

我正在使用 Postgres 8.4。我想使用 plpgsql 和游标更新数据。当我尝试运行 plpgsql 时,它会产生错误。

CREATE OR REPLACE FUNCTION updateScore() 
RETURNS void AS
$$
DECLARE
singleTopicCriteriaPercentage   DECIMAL(6,10);
sitePercentage          DECIMAL(6,10);
singleSiteCriteriaPercentage    DECIMAL(6,10);
totalSocre          DECIMAL(6,10);

cursor1 CURSOR FOR select id from sitereviews order by id;
cursor2 CURSOR FOR select weight into rating from sitereviews_ratingcriteria where site_id = id;

id              sitereviews.id%TYPE;
weight              sitereviews_ratingcriteria.weight%TYPE;

BEGIN
singleTopicCriteriaPercentage := (10 / 120) * 100;
sitePercentage : 0.0;
singleSiteCriteriaPercentage := 0.0;
totalSocre := 0.0;

OPEN cursor1;
LOOP
FETCH cursor1 INTO id;
EXIT WHEN NOT FOUND;
    totalSocre := 0.0;

    OPEN cursor2;
    LOOP
    FETCH cursor2 INTO weight;
    EXIT WHEN NOT FOUND;
        sitePercentage := singleTopicCriteriaPercentage * weight;
        singleSiteCriteriaPercentage :=  (sitePercentage / 100) * 10;
        totalSocre := singleSiteCriteriaPercentage + totalSocre;
    END LOOP;
    CLOSE cursor2;

    update sitereviews set weight = : round(totalSocre)  WHERE CURRENT OF cursor1;
END LOOP
CLOSE cursor1;
END;
$$ LANGUAGE 'PLPGSQL'

以下是尝试运行此程序时的错误:

ERROR: could not load library "C:/Program Files/PostgreSQL/8.4/lib/plpgsql.dll": The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
 SQL state: 58P01
4

1 回答 1

2

看起来您的 PostgreSQL 安装不完整或已损坏。在较旧的 PostgreSQL 安装程序中,plpgsql 是可选的。所以,请检查您的安装。

于 2013-05-15T10:16:00.713 回答