oracle sql 循环一天的数居

-- Created on 2012-6-29 by LIUWEN
declare
  -- Local variables here
  i integer;
  l_begin date;
  l_end date;
begin
  l_begin:=to_date('2012-06-01 00:00:00','yyyy-mm-dd hh24:mi:ss');
  l_end:=to_date('2012-06-02 00:00:00','yyyy-mm-dd hh24:mi:ss');
  -- Test statements here
  while(l_begin<l_end) loop
  dbms_output.put_line('begin:'||to_char(l_begin,'yyyy-mm-dd hh24:mi:ss')||'  end:'||to_char(l_begin+1/24,'yyyy-mm-dd hh24:mi:ss'));
  l_begin:=l_begin+1/24;
  end loop;
end;

------------------------------------------------------------------------------------

-- Created on 2013-10-25 by XYUSER 

declare 

  -- Local variables here

  i integer;

begin

  -- Test statements here

  for cur_v  in(

扫描二维码关注公众号,回复: 1377517 查看本文章

  

    select main_id from T_COMMON_001_MAIN group by main_id having count(*)>1

  ) loop

    

       dbms_output.put_line(cur_v.main_id);

  end loop;

end;

猜你喜欢

转载自thinktothings.iteye.com/blog/1570750
今日推荐