CREATE OR REPLACE FUNCTION get_file_name (p_file IN VARCHAR2) RETURN varchar2
IS
v_file_name VARCHAR2(50);
BEGIN
/*
|| This Function returns a varchar2 string of the file name including the suffix.
|| Written by: Daniel Coe
|| Date: 10/09/2002
*/
IF instr(p_file,’/’) > 0 THEN — Unix

v_file_name := substr(p_file,(instr(p_file,’/’,-1,1)+1),length(p_file));

ELSIF instr(p_file,’\’) > 0 THEN — Windows

v_file_name := substr(p_file,(instr(p_file,’\’,-1,1)+1),length(p_file));

END IF;

RETURN v_file_name;
END;
/

How to get the file name from a full path

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 2 = eight