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;