postgresql 匿名函数(单独执行代码段)

do LANGUAGE plpgsql
$$
declare
  top integer;
  row_org dbo.a_org_type%rowtype;
begin
  /* Insert real code here */
  select into row_org * from dbo.a_org_type order by id desc limit 1;
  top := row_org.id + 1;
  
  for idx in 1..5 loop
    insert into dbo.a_org_type(id, des) 
    values(top, 'shang hai ' || top);
    
    top := top + 1;
  end loop;
  
end;
$$

 

posted on 2018-11-18 08:47  jonney_wang  阅读(2055)  评论(0编辑  收藏  举报

导航