pgsql存储过程


drop function if exists add();
CREATE OR REPLACE FUNCTION add() RETURNS void AS $$

declare 
    userInfo varchar(16) ;
    users refcursor;
begin
OPEN users for EXECUTE 'select clusterId from "dap_model"."dapmanager_cluster" where clustername not in ('defaultCluster','managerService')';

loop
    fetch users into userInfo;
	
	INSERT INTO `dapmanager_usergroup` (cluster_id, group_name,note,visible_status,create_time,latest_update_time,added_by_id,upd_by_id,group_type,cred_store_id,group_src,status,delmark) VALUES (userInfo, 'commongroup', '', '1', '2019-07-08 16:36:51.076', '2019-07-08 16:36:51.076', '0', '0', '1', '0', '0', '0', '0');

end loop;
close users;

end;
$$ language plpgsql;
SELECT add();
DROP FUNCTION add();

 

上一篇:Java入门


下一篇:Linux(CentOS 7)下安装postgres