create or replace function func_togetfilenameanddate(file_name varchar2,type varchar2) return varchar2 is -/*---------------------------------------------------------------------------------------------------------*/ --/*--created by : venkatesan s --------------------------------------------------------------------*/ --/*--datelastmodified : 04-mar-2008 ---------------------------------------------------------------------*/ --/*--purpose : to split the server name and date from file_name --------------------------------*/ --/*--version : 1.0 -----------------------------------------------------------------------------*/ --/*--sample : select func_togetfilenameanddate('svm:01:01:2007','date') from dual; ------------*/ -/*---------------------------------------------------------------------------------------------------------*/ v_file_name varchar2(200 char); --/*--to collect the required details--*/ begin -/*---------------------------------------------------------------------------------------------------------*/ --/*--to extract the server name -----------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------------------------------------*/ if type = 'filename' then v_file_name := substr(file_name,1,instr(file_name,':',1,1)-1); return v_file_name; -/*---------------------------------------------------------------------------------------------------------*/ --/*--to extract the date -----------------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------------------------------------*/
elsif type = 'date' then v_file_name := to_date(substr(file_name,instr(file_name,':',1,1)+1),'dd:mm:yyyy'); return v_file_name; end if; end; /