Examples of Oracle functions and stored procedures

Source: Internet
Author: User

--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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.