Parse for multiple occurences of something in query string used

HI
A varchar is passed as an input to a stored proc. This could have zero, one or more occurances of a word (e.g. from_no). This will be in form of a name value pair and could occur multiple times. Exampe
query_string = ' abc=123 and from_no > 1 and from_no < 10 and def = 1'
Now I need to parse this string to get the operator and values for the 2 occurences of from_no. How can I do that? How can I go about writing a smple func or sp to parse and return both from_no's?

Perhaps this sample code can help:
with yourtable as
(select ' abc=123 and from_no > 1 and from_no < 10 and def = 1' query_string from dual union all
select ' abc=123 and from_no = 2 and from_no != 30 and def = 1 and from_no=40' query_string from dual)
select  query_string,
        x.n no,
        regexp_substr(query_string,'from_no *[<>!=]* *[0-9]*',1,x.n) exp,       
        regexp_replace(regexp_substr(query_string,'from_no *[<!>=]* *[0-9]*',1,x.n),'.*from_no *([<!>=]*) *([0-9]*).*','\1') op,
        regexp_replace(regexp_substr(query_string,'from_no *[<!>=]* *[0-9]*',1,x.n),'.*from_no *([<!>=]*) *([0-9]*).*','\2') val
from yourtable,
     (select rownum n from dual connect by rownum<=100) x
where regexp_instr(query_string,'from_no',1,x.n)>0   --  end searching in query string when there are no more expressions
order by query_string, x.nI added one more example.
It works with your example, but you will have to adapt the code for your real environment.
This code supports only the operators: =, !=, <, >
This code supports only numeric values without decimal-point.
Edited by: hm on 19.10.2010 22:46

Similar Messages

  • How to replace multiple occurences of space in a string to a single space?

    How to replace multiple occurences of space in a string to a single space?

    Hi,
    try this code.
    data : string1(50) type c,
              flag(1) type c,
              dummy(50) type c,
              i type i,
              len type i.
    string1 = 'HI  READ    THIS'.
    len = strlen( string1 ).
    do len times.
    if string1+i(1) = ' '.
    flag = 'X'.
    else.
    if flag = 'X'.
    concatenate dummy string1+i(1) into dummy separated by space.
    clear flag.
    else.
    concatenate dummy string1+i(1) into dummy.
    endif.
    endif.
    i = i + 1.
    enddo.
    write : / string1.
    write : / dummy.

  • Invalid column name in query string - using Format function

    In my post just before this one the problem was solved for writing a query string using a date range. The rest of the query string includes the same date field (Call_Date) but formatted as 'MMM-YY'. I get an invalid column name error when I add this field to the query string. Here is the rest of the query string:
    strSql = "SELECT Format(CALL_DATE,'mmm-yy'), " _
    & "HOME_REGION FROM CCC2.CASE_EPRP " _
    & "WHERE (HOME_REGION = 'NCR') AND " _
    "(CALL_DATE >= to_date( '1/1/2002', 'MM/DD/YYYY' )" _
    & "AND CALL_DATE <= to_date( '2/28/2003', 'MM/DD/YYYY' ))"
    In the Access Query tool I can include this field
    Format(CALL_DATE,'mmm-yy')
    and the query runs fine (I just need to make it dynamic using ADO). But in my ADO query string above, I get the invalid column name error. Is there a way I can include
    Format(CALL_DATE,'mmm-yy')
    in my ADO query string? I appologize for not being more familiar with Oracle Sql. Any help greatly appreciated.
    Thanks again,
    Rich

    Thank you very much for your reply. I think I'm getting closer to the solution. Just I got an error message
    "date format not recognized"
    when I add "to_char( call_date, 'mmm-yy' )" to the query string. I tried using all uppercase, but that did not make a difference. Do I need to use to_date inside the to_char maybe?
    to_char(to_date(call_date, 'mmm/yy'), 'mmm-yy')
    Thanks again for your help.
    Rich

  • Is this a bug or a typo of XML Parser for PL/SQL or something else?

    Hello,
    Below is a piece of codes I copied from the sample that comes with the XML parser for PL/SQL. I found that this sample could not be compiled since:
    1- the method printElements takes in a parameter 'doc' of type 'xmldom.DOMDocument'
    2- then this 'doc' is refered to in API method
    xmldom.getElementsByTagName which takes two parameter, one of type DOMElement, the other of type char.
    Are these tow types compatible?
    where can i get a better documentation for the XML parser for PLSQ, the one come with the zip fileis not up to date since the miss documentation for DOM. thank you.
    BM
    -- prints elements in a document
    procedure printElements(doc xmldom.DOMDocument) is
    nl xmldom.DOMNodeList;
    len number;
    n xmldom.DOMNode;
    begin
    -- get all elements
    nl := xmldom.getElementsByTagName(doc, '*');
    len := xmldom.getLength(nl);
    -- loop through elements
    for i in 0..len-1 loop
    n := xmldom.item(nl, i);
    dbms_output.put(xmldom.getNodeName(n) &#0124; &#0124; ' ');
    end loop;
    dbms_output.put_line('');
    end printElements;

    public  class HelpIcon extends Image 
    The attached snippets showed it extending "mx:Image.
    class HelpIcon extends Image
    [Embed(source="/assets/Info.png")]public var thisIcon:Class;
    The attached snippets showed a type of class.
    Not precisely sure what you are asking. I added the code as you suggested, it still will not honor the click event on the image.
    Here is the code modified as you suggested;
    public class HelpIcon extends Image
      [Embed(source="/assets/Info.png")]
      public var thisIcon:Class;
      public function HelpIcon()
       super();
       this.source = new thisIcon();
       this.addEventListener(FlexEvent.CREATION_COMPLETE,initHelp)
      private function initHelp(event:Event):void
       this.removeEventListener(FlexEvent.CREATION_COMPLETE,initHelp);
       this.addEventListener(MouseEvent.CLICK, helpClicked,true,5); 
    It still does not honor the click event.
    Paul

  • How do you do a search for multiple occurences of the same word in a NOTE?

    How do you search for multiiple occurences of a word in NOTES?  I seem only to be able to find the first occurence and then it goes into a loop, never past the first occurence.

    I want to find all the same words in ONE NOTE. It is a very loong list and I want to find all cccurences of a specific word in that one NOTE when I do a search. I thought I had solved this earlier today but now I can't seem to repeat it. I type in word in the SEARCH box, select the NOTE and then it shows me the FIRST occurence in that note, but only the first,

  • How do i pass a url with query string using the jsp:forward tag

    This snippet of code gives a 403 error
    <jsp:forward page="testpage.jsp?test=1" />
    How do i rectify it?

    Well better way to go about for the job is to use
    setAttribute("name","value");method in the first page
    and then in next page use method
    String s=getAttribute("name");to retreive the value.
    Url rewritting or using Query String has some disadvantages ,which are handled by above mentioned approach.
    Ashish

  • Dynamic orderby clause for multiple columns with out Dynamic query

    Hi,
            I've a query like
    "select  * from tablename order by column1,column2,column3,column4,column5,column6"
    in the above query the order by column will be dynamically changed. The query is placed in a stored procedures and the order by column will come by parameter.
       For ex: @orderbycol = column2,column1,column3,column4,column5,column6
                                         or
                    @orderbycol = column3,column2,column1,column4,column5,coumn6
    How can we manage the order by clause as dynamically without go to dynamic query.

    ORDER BY CASE @sortcol1
                 WHEN 'col1' THEN col1
                 WHEN 'col2' THEN col2
             END,
             CASE @sortcol2
                 WHEN 'col1' THEN col1
                 WHEN 'col2' THEN col2
             END,
    Note: these CASE expressions assumes that all columns have the same data type.
    You could consider sorting in the presentation layer instead.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • FCC's parameters for multiple occurence on target side

    Hi Experts,
    I have an issue in Fixed File content conversion(FCC).
    The fixed format file is being read into XI and is being converted in XML via FCC.
    I have changed the occurence of MT on target side,which resulted in adding Messages & Message1 tag on sender side as well.The structure has become like this:
    Messages
         ->  Message1
              -->  FCI0002_MT
                   --->  row
    >  Fields
    Target str:
    Messages
         ->Message1
              -->FCI002_MT
                   --->row
    >Fields
    If I use FCI0002_MT in document name and row,* in Recordset structure then message mapping fails at MT node.
    What should be the Document name and Recordset structure in the FCC adapter?
    Thanks and Regards,
    Indu Khurana
    Edited by: Indu Khurana on Feb 6, 2009 9:29 AM
    Edited by: Indu Khurana on Feb 6, 2009 9:34 AM

    Hi Mugdha,
    Yes Its has passed FCC and stuck in mapping.
    But now if I change  Recordset structure to :
    Message1,1,FCI000012_Forecast_DATA2000_MT,1,row,*
    then its gving error in communication channel : "  Mandatory parameter 'xml.keyfieldName': no value found  ".
    And in my case I don't have any key field name.
    Kindly suggest.
    Thanks
    Indu

  • Multiple queries happeing in adf query component using LOV

    Hi,
    I am using a programmatic view object in adf query component and have created List of values for one attribute by adding another programmatic ViewObject as ViewAccessor.
    To populate the lov ViewObject, i have overwritten the method executeQueryForCollection in which i call the webservice to fetch the data. So lov is working fine inside QueryComponent.
    I have overwritten queryListener attribute of query component in my backing bean. In the queryListener method, to populate the result grid, am populating the view object by using createRow and insertRow apis. While doing so, Whenever i do setAttibute for the lov field, the overwrittern method executeQueryForCollection getting invoked. Hence my webService getting invoked. So if i have 10 rows, the webservice is getting invoked 10 times.
    I put sops in the executeQueryForCollection method for the queryMode and getName.
    System.out.println("executeQueryForCollection::::"+this.getQueryMode()); i get as 7
    System.out.println("executeQueryForCollection:::=" +this.getName());    i get as  CurrencySummaryLOVVO_5708_findByVC_   The number 5708 varies for every row.
    Please tell me How to avoid invoking the executeQueryForCollection everytime when i do setAttribute.
    One workaround i have currently is to have one dummry attribute for the lov which can be used for display in grid and actual attribute will be used in Query Component for the lov to function.
    Is there any other better workaround?
    Thanks a lot in Advance.
    Vivek
    Edited by: Vivek Singh on Oct 22, 2009 9:16 PM

    When you set a value to LOV field it tries to validate it from the LOV data. thats why it execute query.
    Try setting Row Level Bind Values = false for the accessor.
    yet, i would suggest to find an other way to populate values of LOV since the executeQueryForCollection will be executed many times when you use that LOV:
    [http://adfbugs.blogspot.com/2009/08/lov-execute-query-many-times.html]

  • Parsing Query string using Client Object model [ECMA]

    hello
    i want to access querystring using client object model using ECMA script.
    for eg http://localhost:80/demopage.aspx?test=123
    can we read value of test using ECMA script
    regards
    Manish

    thanks ...
    i did that...using
    <script type="text/javascript">
    function queryString(parameter) {
    var loc = location.search.substring(1, location.search.length);
    var param_value = false;
    var params = loc.split("&");
    for (i=0; i<params.length;i++) {
    param_name = params[i].substring(0,params[i].indexOf('='));
    if (param_name == parameter) {
    param_value = params[i].substring(params[i].indexOf('=')+1)
    if (param_value) {
    return param_value;
    else {
    return false; //Here determine return if no parameter is found

  • Query for multiple invoice numbers.

    Hi,
    My question is if I can add multiple invoice numbers in the search field "invice number"?
    For example when I receive a balance confirmation request from a supplier and their list contains 10 invoices. Can I do a search for all 10 at the same time or I can olny do a search one by one?
    Thank you!
    Angie

    Hi,
    there's no direct possibility to query for multiple Invoice number in terms of entering e.g. 5 number for a query.
    But you can work with placeholders '_' and '%' to find multiple invoices at one time. Underscore sign stands
    for exactly one character which can have multiple value, percentage sign for multiple ones.
    Example (assuming you are using letters and numbers for invoice numbering):
    When entering 'A12_' as search String, invoices from 'A120' to 'A12z' would be found.
    When using 'A12_01_' all invoices from 'A120010' to 'A12z01z' would be found.
    When using 'A12%' all invoices starting with 'A12' - no matter about the rest would be found.
    These are only a few examples but i think when using a clever combination of wildcards and parts of the
    invoices - which often share a common component, if the invoices come from the same vendor - you'll get
    at least a small step farther.
    Regards

  • Parsing query string

    I am using ALSB 3.0
    If I parse the query string using the following:
    $inbound/ctx:transport/ctx:request/http:query-string/text()
    when the passed data is the following:
    https://webservicesdev.someplace.com/testing/order/163625/results?p1=Normal&p2=Complete
    I get the following string:
    p1=Normal
    Why does my query string not contain all of the parameters? How do I get access to the p2=Complete part of the query string?
    Thanks,
    Dave

    Thank you both for your response. The problem was more related to how I was attempting to test the service. I was using a curl script on a Unix box and my query string was being truncated at the & character. Once I tried testing directly with a browser, then I was seeing the full query string.
    Once I had the full query string I was able to use the following to parse the query string:
    let $parsed_query_string := tokenize( $a_query_string, "&amp;" )
    ["&" above is really "& amp ;" without the spaces]
    Where $a_query_string had previously been assigned to string( $inbound/ctx:transport/ctx:request/http:query-string/text() )
    Thanks again,
    Dave
    Edited by: dschmidt on Jan 25, 2011 1:53 PM

  • Regarding Print of Single Form for multiple Transfer Order  ( LT03 )

    Hi All,
    When user creates Transfer Order and if transfer order items are more than 22 then split of Transfer Order occurrs and multiple TO's get created in system.  The standard prog. RLVSDR40 prints form for each TO's , however the requirment is to print only one form for multiple TO ( Actually TO Form containes info. abt delivery, but triggering point should be from TO creation ) .
    There is one prog. RLKOMM40 which is used for multiple processing,  whether this prog. will be useful for above requirement.  Or is there any exit available for above requirement .
    Thanks for help.

    Hi,
      is there any routines used in Copy controls from order - delivery .- re-check once.
    as your post, everything seems fine. I didnt see any reason for not creating single delivery.
    is it happening only with this customer or respective ship to's? if yes, something gone wrong in CMR - i.e. complete delivery / order combination etcc., ( just an assumption)
    Regards,
    ReazuddinMD

  • Itunes for multiple family members

    My situation is I've been using iTunes since its inception and built quite a library. I've been through multiple ipods and now on to iphones for multiple family members. All the while using one itunes account on separate devices for multiple family members. Now that we have iphones its become necessary to create separate icloud accounts for each family member. This creates a problem for those with new icloud accounts. The iTunes music library can no longer be shared on separate devices (that I know of). The music library and playlists I have built over years cannot be shared with those devices that now have separate icloud accounts. I am aware of "family sharing" and have set that up going forward but how do I resolve the issue of all the music and playlists that were shared when we all used one itunes account, prior to creating separate icloud accounts? I hope this makes sense. For example my wife and son no longer have access to any of the music/playlists on their iphones that they used to have prior to creating their own accounts. Even though all purchases made before and after creating separate icloud accounts were made using the same credit card.
    I believe I could just go back to having the other devices sign back into my itunes account and I think that may resolve the issue but what happens to purchases that were made on the other devices while they were signed into their own accounts? Another point that comes up is that we all have gift card balances on each itunes account. This is so confusing

    This is great news as I've been struggling with this issue for some time. Mainly because my wife is a little old school and likes to put music on CD's and this solves that problem. Thanks again!!
    Mr Mars,
    You are welcome!  I hope you have achieved the expected degree of "harmony." 
    Family Sharing:  A new way to bring harmony to your family’s digital life
    Ed.

  • How to use one email adress for multiple recipients

    Hello,
    I'd like to know how to use one email adress for multiple recipients. 
    this would be very useful or projects. for example;
    if i send one mail to [email protected], all people in this project get an email.
    I will add the people in this project myself. 
    I know it is possible, but I don't know how to do it ;-)
    please help me! 

    Hope this help.
    _http://technet.microsoft.com/en-us/library/cc164331(v=exchg.65) .aspx

Maybe you are looking for