相关疑难解决方法(0)

将PL/pgSQL SELECT转换为数组

这是我的函数声明和正文的一部分:

CREATE OR REPLACE FUNCTION access_update()
RETURNS void AS $$
DECLARE team_ids bigint[];
BEGIN
    SELECT INTO team_ids "team_id" FROM "tmp_team_list";

    UPDATE "team_prsnl"
    SET "updt_dt_tm" = NOW(), "last_access_dt_tm" = NOW()
    WHERE "team_id" IN team_ids;
END; $$ LANGUAGE plpgsql;
Run Code Online (Sandbox Code Playgroud)

我想team_ids成为一个我可以在UPDATE声明中使用的一组int .这个函数给我这样的错误:

psql:functions.sql:62: ERROR:  syntax error at or near "team_ids"
LINE 13:  AND "team_id" IN team_ids;
Run Code Online (Sandbox Code Playgroud)

sql postgresql plpgsql postgresql-9.1

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

plpgsql ×1

postgresql ×1

postgresql-9.1 ×1

sql ×1