COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: div_1234 on 30 Aug 2011 01:02:32 PM

Title: any function of replace
Post by: div_1234 on 30 Aug 2011 01:02:32 PM
hi
Is there any function , which works like replace  in expression


Thansk
Title: Re: any function of replace
Post by: lucasdnd on 30 Aug 2011 03:11:27 PM
replace("old substring", "your original string", "new substring")

Example:
replace("ello", "Hello world", "i") returns:
"Hi world"
Title: Re: any function of replace
Post by: div_1234 on 30 Aug 2011 04:04:17 PM
i cant use replace function in cognos expression,i need to find similar function which i can use
Title: Re: any function of replace
Post by: lucasdnd on 30 Aug 2011 04:16:29 PM
Can't use the replace function? That's weird. As far as I know, it's the only easy way to do it. Are you sure the parameters passed to the function are all Strings?
Title: Re: any function of replace
Post by: div_1234 on 31 Aug 2011 02:29:13 PM
yes they all r string
Title: Re: any function of replace
Post by: Lynn on 31 Aug 2011 03:28:57 PM
Functions available to you and their syntax can sometimes vary depending on the database you are using.

If you post what DBMS you are reporting against, it may help you get better responses to your question.

Some databases have a "translate" function that may help you achieve something similar to "replace".
Title: Re: any function of replace
Post by: div_1234 on 31 Aug 2011 03:54:01 PM
i am using sql server , but there is no function in expression replace

Title: Re: any function of replace
Post by: Lynn on 01 Sep 2011 07:47:57 AM
Quote from: div_1234 on 31 Aug 2011 03:54:01 PM
i am using sql server , but there is no function in expression replace

I'm not using SQL Server currently, but I'm pretty sure that it supports the replace function:
http://msdn.microsoft.com/en-us/library/ms186862.aspx

I don't understand what you mean when you say you can't use it? Did you try and get an error? Just because you don't see it listed in the functions tab on the expression editor doesn't mean you can't use it (in case that is the issue).
Title: Re: any function of replace
Post by: div_1234 on 01 Sep 2011 08:39:55 AM
hi
i am getting error like the function name was not found near the position 80. CRX-API-0011