COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Framework Manager => Topic started by: cogboy on 30 Oct 2007 12:03:46 PM

Title: Splitting URL path
Post by: cogboy on 30 Oct 2007 12:03:46 PM
Hello Everyone

I have a cloumn which gives me URl paths for different file locations.
For Example:  http://cdrive/good/eater.pdf
                   http://fdrive/bater.pdf

So i need to extract only Bold part of url.Means i need to get only part after last '/'.

if any one have any ideas please share with me.

Thanks
Vin
Title: Re: Splitting URL path
Post by: COGNOiSe administrator on 31 Oct 2007 10:06:47 AM
LastIndexOf('/') ?
Title: Re: Splitting URL path
Post by: cogboy on 31 Oct 2007 11:09:29 AM
Thanks for your response

url path is my query item.So I have to create a calculation which gives me
that file name.

I am unable to use lastindexof.

Please give me your suggestion.

Thanks
cogboy
Title: Re: Splitting URL path
Post by: almeids on 31 Oct 2007 12:58:02 PM
if on Oracle try:
substr([url path],instr([url path],'/',-1)+1)
Title: Re: Splitting URL path
Post by: COGNOiSe administrator on 31 Oct 2007 01:34:57 PM
Keep in mind thay you can add ANY function to Cognos Suite. Even a non-database one if I understand the Framework correctly. It is just a matter of how much effort would you like to invest.
Title: Re: Splitting URL path
Post by: cogboy on 01 Nov 2007 09:05:39 AM
I am on Sql not on oracle but any ways i appreciate yur response
Title: Re: Splitting URL path
Post by: almeids on 01 Nov 2007 12:37:43 PM
I imagine that your database has similar functions for extracting a portion of a string or locating a string within a string, perhaps you could extrapolate from the Oracle example.
Title: Re: Splitting URL path
Post by: praveennb on 01 Nov 2007 10:18:56 PM
This should work on SQL Server.

Sample
declare @str varchar(50)
set @str='http://cdrive/good/eater.pdf'
select reverse(substring(reverse(@str),1,charindex('/',reverse(@str))-1))

in your  FM query replace the bold part with your column name
select reverse(substring(reverse(@str),1,charindex('/',reverse(@str))-1))