Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

String manipulation that includes dbl quotes

What is the best way to do string manipulations when the string has double quotes. Say if I want to change a SQL where clause into a report header:

(("Health Code" = 'Asthma') AND ("Disease Severity"='Severe))...

into

Health Code = Asthma
Disease Severity = Severe
...

The problem is that the string functions in both js and asp cannot handle the double quotes. Any ideas???

Thanks!


Comments

  • gigsvoogigsvoo Posts: 328Member
    :
    : (("Health Code" = 'Asthma') AND ("Disease Severity"='Severe))...
    :

    First of all, are [b]Health Code[/b] and [b]Disease Severity[/b] fields names?

    Please write your complete SQL statement for easier debugging.

    [size=2]Neo Gigs[/size]
    [color=blue]http://communities.msn.com.my/VisualBasicwithNeo[/color]

  • elcaro2kelcaro2k Posts: 5Member
    When I get to a point in a Cognos cube, I can do a drill through which sends the query string as part of the URL. I tell Cognos the web page to open but that is the only control I have until it gets to the page. When my page opens I extract the string from the URL by using:

    unescape(Request.Form("filter")

    which gives a string typical of the one below:

    (("Incurred As Of Date" BETWEEN DATE '2001-06-01' AND DATE '2001-06-30') AND ("Health Mgmt Disease Name"='Asthma') AND ("Disease Severity Name"='Mild') AND ("Age Group Name"='5 to 9 years old' AND "Age Group Category Name"='Children') AND ("Gender Code"='MALE') AND ("Region Name" LIKE 'CENTRAL MO OTHER' AND "Region Category Name"='Central MO'))

    I then concat this where clause to a SQL statement and go to Oracle to populate my table on the page. I would just like to break this apart to generate a header for the report. The dbl quotes stop me in my tracks when I try to use replace functions and the like.
  • gigsvoogigsvoo Posts: 328Member
    Try to use single quotes?

    [size=2]Neo Gigs[/size]
    [color=blue]http://communities.msn.com.my/VisualBasicwithNeo[/color]

  • elcaro2kelcaro2k Posts: 5Member
    Here is the solution that I came up with:


    <%@LANGUAGE = VBScript %>
    <%Option Explicit%>




    Specialized Drill Through Program


    The list of parameters passed in was:




    <%
    dim mytest
    dim re
    dim patt
    dim myarray
    dim i
    dim testval


    set re = new regexp
    re.global = true

    mytest = Request.Form("filter")

    patt = "x22"
    re.Pattern = patt
    mytest= re.replace(mytest,"")

    patt = "x29"
    re.Pattern = patt
    mytest= re.replace(mytest,"")

    patt = "x28"
    re.Pattern = patt
    mytest= re.replace(mytest,"")

    patt = "'"
    re.Pattern = patt
    mytest= re.replace(mytest,"")

    patt = "DATE"
    re.Pattern = patt
    mytest= re.replace(mytest,"")

    patt = "AND"
    re.Pattern = patt
    mytest= re.replace(mytest,"")

    response.write("<br>")
    response.write("
    ")


    myarray = split(mytest,"")
    for i = 0 to 3'(split(mytest,""))
    Response.Write(myarray(i))
    Response.write("
    ")
    next

    %>





  • elcaro2kelcaro2k Posts: 5Member
    [b][red]This message was edited by elcaro2k at 2002-9-4 4:0:35[/red][/b][hr]
    Yes, remember I am just creating a header for the report (table). I pass the string as I get it from Cognos to Oracle with no changes.



  • Anjuna MoonAnjuna Moon Posts: 89Member
    Why don't you just use ordinary Replace and save some unnecessary code:

    str=Replace(str,chr(34),"")

    Also, in VBScript when dealing with dbl-quotes you can represent one(1) double-quote as "". In the example above that would be:

    str=Replace(str,"""","")

    /Chris
  • elcaro2kelcaro2k Posts: 5Member
    even better, Thanks!!!

Sign In or Register to comment.