小编Ale*_* H.的帖子

plpgsql语法错误在";"附近

我看过这个类似的问题,但我认为我的问题可能有所不同.如果我正确理解他们的问题,问题是由上游的语法错误引起的.
在我的情况下,语法错误是如此接近程序的开头,它给了我一个可能出错的窗口,但是一切看起来都没问题.

码:

DO $$
DECLARE topic_cursor CURSOR FOR SELECT * FROM "socialMediaModel_topic" WHERE "active_search"=True;

BEGIN
OPEN topic_cursor;
FETCH FIRST FROM topic_cursor;
LOOP
    SELECT "topic" FROM topic_cursor AS "c_topic";
    SELECT "topic_id" FROM topic_cursor AS "c_id";
    SELECT "active_search" FROM topic_cursor AS "c_active";

    INSERT INTO "socialMediaModel_datacollection" ("name", "active")
        VALUES (c_topic, c_active);
    INSERT INTO "socialMediaModel_datacollectiontopic" ("data_collection_id_id", "topic_id_id")
        VALUES ((SELECT "data_collection_id" FROM "DataCollection" where name=c_topic), c_id);

    FETCH NEXT FROM topic_cursor;

END LOOP;
CLOSE topic_cursor;

UPDATE "socialMediaModel_topic" SET "active_search" = False WHERE "active_search"=True; …
Run Code Online (Sandbox Code Playgroud)

sql postgresql plpgsql cursor window-functions

3
推荐指数
1
解决办法
3406
查看次数

标签 统计

cursor ×1

plpgsql ×1

postgresql ×1

sql ×1

window-functions ×1