×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: SQL
Posted by: Jon Nickerson
Added: Mar 16, 2018 2:38 PM
Modified: Mar 16, 2018 3:42 PM
Views: 4
Tags: no tags
  1. CREATE OR REPLACE FUNCTION get_dir_path
  2.    (p_path IN VARCHAR2)
  3.    RETURN varchar2
  4. IS
  5.    v_dir VARCHAR2(1500);
  6. BEGIN
  7.    IF (SUBSTR(p_path, -1, 1) = '\' or SUBSTR(p_path, -1, 1) = '/') THEN
  8.      v_dir := p_path;
  9.   -- Parse string for UNIX system
  10.   ELSIF INSTR(p_path,'/') > 0 THEN
  11.      v_dir := SUBSTR(p_path,1,(INSTR(p_path,'/',-1,1)-1));
  12.   -- Parse string for Windows system
  13.   ELSIF INSTR(p_path,'\') > 0 THEN
  14.      v_dir := SUBSTR(p_path,1,(INSTR(p_path,'\',-1,1)-1));
  15.   -- If no slashes were found, return the original string
  16.   ELSE
  17.      v_dir := p_path;
  18.   END IF;
  19.   RETURN v_dir;
  20. END;