postgresql实现简单的循环函数
发布时间:2020-12-13 17:09:56 所属栏目:百科 来源:网络整理
导读: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 (num6) then num =
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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |