一些数据库的循环方法
时间:2022-03-14 02:27
一些数据库的循环方法:
Mysql
- myLoop;
- myLoop(begin_date (10), end_date (10))
- ???? v_date ;
- ???? v_begin_date, v_end_date (10);
- ???? v_date = begin_date;
- ???? v_date < end_date do
- ???????? v_begin_date = DATE_FORMAT(v_date,‘%Y-%m-%d‘);
- ???????? v_date = DATE_ADD(v_date, 1 );
- ???????? v_end_date = DATE_FORMAT(v_date,‘%Y-%m-%d‘);
- ???????? v_begin_date, v_end_date;
- ????????-- write your sql here!
- ???? ;
- ;
- -- call myLoop(‘2013-08-15‘,‘2013-09-02‘);
?
?
Oracle
- ???????v_date ;
- ???????v_begin_date 2(10);
- ???????v_end_date 2(10);
- ???????v_date := ‘2014-06-02‘;
- ??????? v_date < ‘2014-06-20‘ loop
- ?????????????v_begin_date := to_char(v_date, ‘yyyy-mm-dd‘);
- ?????????????v_date := v_date + 1;
- ?????????????v_end_date := to_char(v_date, ‘yyyy-mm-dd‘);
- ?????????????dbms_output.put_line(v_begin_date||‘ === ‘||v_end_date);
- ?????????????-- write your sql here!
- ????????? loop;
- ?????????;
- ;