dbTalk Databases Forums  

replace

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss replace in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kasper Birch Olsen
 
Posts: n/a

Default replace - 07-04-2005 , 03:51 AM






Hi NG

Im tryinng to replace chars in a string in an url-action, to ensure that the
chars are URL encoded correctly. Replace doesnt work, what does?

example:
replace("http://localhost/mypage.aspx?arg="+[store].CurrentMember.UniqueName,
"&", "&")

but no, replace returns "http://???", not quite what i was hoping for
Any ideas?

- Kasper



Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: replace - 07-05-2005 , 08:03 PM






This table indicates Replace() is not yet supported:

http://msdn.microsoft.com/library/de.../en-us/dnexcl2
k2/html/odc_xlsql.asp
Quote:
Visual Basic for Applications Functions
...
Functions not supported in this release are marked by an asterisk in
this table.
...
*Replace
Quote:

Here is a rather convoluted solution, borrowing both from sample VBA
code, and from earlier posts to this NG which used Calculated Cells for
MDX iteration:

Quote:
With Member [Measures].[ReplaceURL] as
'"http://localhost/mypage.aspx?arg= [store].&[1].&[2].&[3].&[4]"'

Member [Measures].[LeftReplace] as
'Left([Measures].[ReplaceURL],
InStr([Measures].[ReplaceURL], "&[") - 1)
+ "&amp"+ Right([Measures].[ReplaceURL],
Len([Measures].[ReplaceURL])
- InStr([Measures].[ReplaceURL], "&["))'

Cell Calculation [ReplaceAnd]
For '({[Measures].[ReplaceURL]})'
As 'iif(Instr(CalculationPassValue([Measures].[ReplaceURL], -1,
RELATIVE), "&[") = 0,
CalculationPassValue([Measures].[ReplaceURL], -1, RELATIVE),
CalculationPassValue([Measures].[LeftReplace], -1, RELATIVE))',
CALCULATION_PASS_DEPTH = 4,
CALCULATION_PASS_NUMBER = 5

select {[Measures].[ReplaceURL]} on columns
from Sales
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.