软件下载吧文章资讯

分类分类

postgresql 循环函数的简单实现操作

2024-03-07 21:27作者:下载吧

我就废话不多说了,大家还是直接看代码吧~

create or replace function aa1(a1 integer[],a2 bigint) returns
void AS $$
declare ii integer;
declare num integer;
begin
II:=1;
num = 1;
FOR ii IN 1..a2 LOOP
UPDATE student SET
id=a1[num]
WHERE cd_id = ii;
num = num +1;
if (num>6) then
num = 1;
end if;
end loop;
end;
$$ LANGUAGE plpgsql;

select aa1(array[1,4,5,6,7,8],6742)

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消