CREATE OR REPLACE FUNCTION LBI_SYS_VDF.FUN_SYS_GET_CALENDAR_WEEK
(
iv_date varchar2,
ii_calendar_flag number,
ii_action_flag number
)
/** head
* @name lbi_sys#fun_sys_get_calendar_week
* @caption automatic get the what's the week input day is.
* @type primarily management program
* @parameter iv_date in varchar2 deal date.Formate:yyyymmdd
* @parameter ii_calendar_flag in number execute state:
0 means first week start with Jan 1st ;
1 means first week start with the first sunday of the year.
other means error
* @parameter ii_action_flag in number execute state:
0 means get the add week ;
1 means delete the old week.
2 means it's not about t_s_det_week table
* @description automatic management of partition by day
* @target
* @source
* @middle
* @version 1.0.000
* @author wenchenteng
* @create-date
* @todo
* @author
* @create-date 2012-07-31
* @description
* @copyright Huawei
*/
return varchar2
as
vd_deal_date date; --The date you want to deal with
vd_flag_date date; --The data for checking whether Jan 1st is sunday
vi_flag_week integer; --The number of dealing week in The t_s_det_week table
vd_first_week_date date; --The first sunday of the year when Jan 1st is not the first sunday
vd_first_week_date1 date; --The first sunday of the last year when Jan 1st is not the first sunday
vi_loop_num integer := 1; -- The number for checking the
vi_minus_num integer; -- The minus number of dealing date minus first sunday
vi_minus_num1 integer; -- The minus number of last date of last year minus first sunday
ov_return varchar2(6); -- The return week
oi_return integer; --The result code when excetion
exc_calendar_err exception; -- The exception for insert or delete error
begin