An example of a function

xiaoxiao2021-03-06  40

Create or replace function "fetchname" (v_cdno varcha2, v_type varcha2, v_pmodid varcha2) Return varchar2isv_name varchar2 (50); Begin

v_name: = ''; if v_type = 'application' then select ap_appname into v_name from application where ap_appid = v_cdno; return v_name; elsif v_type = 'module' then if v_cdno = '0' then select mo_modname into v_name from module where mo_modid = v_pmodid; else select mo_modname into v_name from module where mo_modid = v_cdno; end if; return v_name; elsif v_type = 'metafunction' then select me_metaname into v_name from metafunction where me_metaid = v_cdno; return v_name; elsif v_type = 'company' then select cmpname into v_name from company where cmpcmpcd = v_cdno; return v_name; elsif v_type = 'TRD' then select trdname into v_name from trade where trdcd = v_cdno; return v_name; elsif v_type = 'oprdept' then select de_deptName into v_name from department where de_deptid = v_cdno ; return v_name; elsif v_type = 'EDU' then select cstnm into v_name from cnst where csttp = 'EDU' and cstcd = v_cdno; return v_name; elsif v_type = 'SEX' then select cstnm into v_name from cnst where csttp = 'SEX' And cstcd = v_cdno; return v_name; elsif v_type = 'STP' then select cstnm into v_name from cnst where csttp = 'STP' and cstcd = v_cdno; return v_name; elsif v_type = 'SJB' then select cstnm into v_name from cnst where csttp = 'SJB 'and cstcd = v_cdno; return v_name; elsif v_type =' STA 'then select cstnm into v_name from cnst where csttp =' STA 'and cstcd = v_cdno; return v_name; elsif v_type =' EMP 'then select cstnm into v_name from cnst where CSTTP = 'EMP' and CSTCD =

v_cdno; return v_name; elsif v_type = 'CMP' then select cstnm into v_name from cnst where csttp = 'CMP'and cstcd = v_cdno; return v_name; elsif v_type =' rgn 'then select cstnm into v_name from cnst where csttp =' RGN 'and cstcd = v_cdno; return v_name; elsif v_type =' CET 'then select cstnm into v_name from cnst where csttp =' CET'and cstcd = v_cdno; return v_name; elsif v_type = 'DPT' then select de_deptName into v_name from department where de_deptid = v_cdno; return v_name; elsif v_type = 'RGN' then select rgnname into v_name from region where rgncd = v_cdno; return v_name; elsif v_type = 'HRR' then select cstnm into v_name from cnst where csttp = 'RGN'and cstcd = v_cdno; return v_name; elsif v_type = 'CMPNAME' then select cmpname into v_name from company where cmpcmpcd = v_cdno; return v_name; elsif v_type = 'pSTNAME' then select pstname into v_name from post where pstcd = v_cdno; return v_name; elsif v_type = 'OPR' Then SELECT US_USERNAME INTO V_NAME from UserInfo Where US_UserId = V_CDNO; RETU Rn v_name; Elsif v_type = '111' Then IF v_cdno = '11 'TENV_NAME: =' <= 15 '; ELSIF V_CDNO = '12' TENV_NAME: = '15-20'; ELSIF V_CDNO = '21 'Then v_name : = '20-25'; Elsif v_cdno = '22 'TENV_NAME: =' 25-30 '; Elsif v_cdno = '31' Then V_Name: = '30-35'; ELSIF V_CDNO = '32 'Then v_name: = '35 -40 '; Elsif v_cdno = '41'

转载请注明原文地址:https://www.9cbs.com/read-51362.html

New Post(0)