|
|
CREATE OR REPLACE FUNCTION Get_table_model(vname in varchar2
,v_flag in varchar2 default 'N'-----首字母是否小寫-------
,v_col in varchar2 default 'Y' ----是否欄位
) RETURN varchar2 IS
/******************************************************************************
NAME: Get_table_model
description 根據表名或欄位名,獲得Model名
******************************************************************************/
v_str varchar2(255);
v_temp varchar2(255);
v_temp1 varchar2(255);
BEGIN
if v_col = 'N' then
v_temp:=substr(vname,instr(vname,'_')+1);
v_temp1:=substr(vname,instr(vname,'_')+1);
else
v_temp:=vname;
v_temp1:=vname;
end if;
if vname is not null then
loop
if v_flag = 'Y' then
if v_temp = v_temp1 then
if instr(v_temp,'_') =0 then
v_str:=v_str||lower(v_temp);
else
v_str:=v_str||lower(substr(v_temp,0,instr(v_temp,'_')-1));
end if;
else
if instr(v_temp,'_') =0 then
v_str:=v_str||initcap(v_temp);
else
v_str:=v_str||initcap(substr(v_temp,0,instr(v_temp,'_')-1));
end if;
end if;
else
if instr(v_temp,'_') =0 then
v_str:=v_str||initcap(v_temp);
else
v_str:=v_str||initcap(substr(v_temp,0,instr(v_temp,'_')-1));
end if;
end if;
exit when instr(v_temp,'_') = 0;
v_temp:=substr(v_temp,instr(v_temp,'_')+1);
end loop;
null;
end if;
return v_str;
END Get_table_model;
/ |
|