Create simple functions in oracle

Source: Internet
Author: User

Create or replace function hello www.2cto.com /**************************** * ***************************** Author: fuqiang WX155924 Version: v1.00 Date: 2013-01-06 Description: move a directory ************************************* * ***************/(I _source_objid IN VARCHAR2, -- original directory objectid I _tag_objid IN VARCHAR2 -- to move to the target objectid -- o_resulet out number) RETURN INT AS -- Migration successful 1: Failed 0: Success v_sourcePid VARCHAR2 (30 ); -- source directory Pid v_tagpid VARCHAR2 (30); -- target directory Pid BEGIN -- entry parameter judgment IF I _source_objid is null or I _tag_objid IS NULL THEN RETURN 1; END IF; -- store their respective pid select category. parentid into v_sourcePid from T_CMP_TYPE_CATEGORY category where category. objectid = I _source_objid; select category. parentid into v_tagpid from T_CMP_TYPE_CATEGORY category where category. objectid = I _tag_objid; if v_sourcePid = v_tagpid then RETURN (1); end if; -- Update I _tag_objid if needed> I _tag_objid then when moving up -- (source directory) update T_CMP_TYPE_CATEGORY t set t. objectid = I _tag_objid where t. parentid = v_sourcePid and t. objectid = I _source_objid; -- (target directory) update T_CMP_TYPE_CATEGORY t set t. objectid = I _source_objid where t. parentid = v_sourcePid and t. objectid = I _tag_objid; ------------------------ update T_CMP_EXT_MEDIACATEGORY -------------------- -- (source directory) update T_CMP_EXT_MEDIACATEGORY t set t. objectid = I _tag_objid where t. objectid = I _source_objid; -- update (target directory) update T_CMP_EXT_MEDIACATEGORY t set t. objectid = I _source_objid where t. objectid = I _tag_objid; ---------------------- update T_CMP_TYPE_MEDIACATEGORY ---------------------- -- (source directory) update T_CMP_TYPE_MEDIACATEGORY t set t. objectid = I _tag_objid where t. objectid = I _source_objid; -- (target directory) update T_CMP_TYPE_MEDIACATEGORY t set t. objectid = I _source_objid where t. objectid = I _tag_objid; ------------------------ update mdsp_t_categoryinfo ---------------------- -- (source directory) update mdsp_t_categoryinfo t set t. objectid = I _tag_objid where t. objectid = I _source_objid; -- (target directory) update mdsp_t_categoryinfo t set t. objectid = I _source_objid where t. objectid = I _tag_objid; RETURN 0; end if; EXCEPTION WHEN OTHERS THEN RETURN 2; END hello;

Related Article

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.