--查询表资料
SELECT * FROM gl_period_statuses;YM
2013-07
2013-08
2013-09
2013-10
2013-11
2013-12--创建procedure
CREATE OR REPLACE procedure test as
cnt varchar2(3);begin
dbms_output.put_line('期间'||' '||'天数');--此处只用于测试,一般procedure不会这么写
for rows in (select ym from gl_period_statuses) loop
select to_char(last_day(to_date(rows.ym,'yyyy-mm')),'dd') into cnt from dual;
dbms_output.put_line(rows.ym||' '||cnt);
end loop;
EXCEPTION WHEN OTHERS THEN
RAISE;
end test;--调用
exec test;--执行结果 期间 天数
2013-07 31
2013-08 31
2013-09 30
2013-10 31
2013-11 30
2013-12 31
Total execution time 0.016 sec.
select ym as"期间",to_char(last_day(to_date(rows.ym,'yyyy-mm')),'dd')"天数" from gl_period_statuses;