您的位置:首页 > 博客中心 > 数据库 >

一些数据库的循环方法

时间:2022-03-14 02:27

一些数据库的循环方法:

Mysql

  1. myLoop;
  2. myLoop(begin_date (10), end_date (10))
  3. ???? v_date ;
  4. ???? v_begin_date, v_end_date (10);
  5. ???? v_date = begin_date;
  6. ???? v_date < end_date do
  7. ???????? v_begin_date = DATE_FORMAT(v_date,‘%Y-%m-%d‘);
  8. ???????? v_date = DATE_ADD(v_date, 1 );
  9. ???????? v_end_date = DATE_FORMAT(v_date,‘%Y-%m-%d‘);
  10. ???????? v_begin_date, v_end_date;
  11. ????????-- write your sql here!
  12. ???? ;
  13. ;
  14. -- call myLoop(‘2013-08-15‘,‘2013-09-02‘);

?

?

Oracle

  1. ???????v_date ;
  2. ???????v_begin_date 2(10);
  3. ???????v_end_date 2(10);
  4. ???????v_date := ‘2014-06-02‘;
  5. ??????? v_date < ‘2014-06-20‘ loop
  6. ?????????????v_begin_date := to_char(v_date, ‘yyyy-mm-dd‘);
  7. ?????????????v_date := v_date + 1;
  8. ?????????????v_end_date := to_char(v_date, ‘yyyy-mm-dd‘);
  9. ?????????????dbms_output.put_line(v_begin_date||‘ === ‘||v_end_date);
  10. ?????????????-- write your sql here!
  11. ????????? loop;
  12. ?????????;
  13. ;

热门排行

今日推荐

热门手游