--for the resulting UUID to conform to the RFC 4122 standard (http://tools.ietf.org/html/rfc4122), for example: A8f662b8-6e7a-13fe-e040-970a437c6bd7
--function
CREATE OR REPLACE
FUNCTION Get_uuid
RETURN VARCHAR
Is
GUID VARCHAR (50);
BEGIN
GUID: = Lower (Rawtohex (Sys_guid ()));
RETURN
substr (guid,1,8) | | ' -' | | substr (guid,9,4) | | ' -' | | substr (guid,13,4) | | ' -' | | substr (guid,17,4) | | ' -' | | SUBSTR (guid,21,12);
END Get_uuid;
--Function: Carry-over. For example, the current date is August 31, August is not data, you need to copy the July data as a August
Create or Replace procedure Fys_sch_lvyou2_carryover (syear in Varchar2,smonth in varchar2)--Note: The year of the closing is required
Is
Cursor T_rows is a select t.* from Lvyou2_bak t where T.remarks=smonth and t.year=syear;
Tmonth VARCHAR2 (10);
T_row T_rows%rowtype;
Begin
Dbms_output.enable (100000);
For T_row in T_rows
Loop
Tmonth:=to_char (Add_months (to_date (t_row.year| | -' | | T_row.remarks, ' yyyy-mm '), 1), ' yyyy-mm ');--the year of the carry-over
Dbms_output.put_line (Tmonth);
INSERT into Lvyou2_bak values (Get_uuid (),--uuid
substr (tmonth,0,4),--year
T_row.classification,
T_row.num,
substr (tmonth,6,2),--Month
T_ROW.REMARKS1,
T_ROW.REMARKS2,
T_ROW.REMARKS3,
T_ROW.REMARKS4,
T_ROW.REMARKS5,
‘‘,‘‘,‘‘,‘‘,‘‘
);
End Loop;
Commit
exception
When others and then rollback;
End
Examples of Oracle functions and stored procedures