SET TERM ^ ; create ExtractFileName( FILEPATH varchar(360) DEFAULT 'D:\Program Files\Firebird\Firebird_2_5\firebird.log' ) RETURNS ( FILENAME varchar(360) ) AS declare variable Loop_Break smallint default 0; declare variable POS_BK_SLASH smallint default 0; declare variable pathlength smallint default 0;
BEGIN Loop_Break = 0; while(0 = :Loop_Break) do begin select position('\' in :FilePath) from RDB$DATABASE into :POS_BK_SLASH; if(0 != :POS_BK_SLASH) then begin pathlength = char_length(FilePath); FileName = substring(:FilePath from :POS_BK_SLASH+1 for :pathlength - :POS_BK_SLASH + 1); FilePath = :FileName; end else begin Loop_Break = 1; end end suspend; END^ SET TERM ; ^ On Thu, Sep 17, 2015 at 7:49 PM, 'stwizard' stwiz...@att.net [firebird-support] <firebird-support@yahoogroups.com> wrote: > > > Greetings All, > > > > Firebird v1.5.3 and v2.5.4 > > > > I need a way to extract just the file name for a given file path either by > code in a stored procedure or by calling a UDF in the stored procedure. > > > > Example, I need to extract “SNKSAid.dat” from > “K\Frontline\Documents\Aids\SNKSAid.dat” > > > > Any ideas? > > > > Thanks, > > Mike > > > -- Regards, Lt Col (Retd) Rajiv D.S. Chauhan in.linkedin.com/in/ltcolrdschauhan _____________________________