postgres循环sql

时间:2018-05-21 16:24:21   收藏:0   阅读:985
CREATE OR replace function loop_addDevice(i integer) RETURNS integer as
$$
    declare 
    count alias for $1;
    all_cam int;
    num_cam int;
    begin
    all_cam :=10;
    while all_cam>0  Loop
      insert into ...
      all_cam:=all_cam-1;
  end loop; return 0; end; $$ LANGUAGE plpgsql; --连接到wsw \c wsw --先清空表 truncate encodedevice; truncate element; truncate area; truncate camera; select loop_addDevice(5000);

 

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!