To find position of a string in given string

I am trying to find out a position of string1 in string 2 using CHARINDEX function.
Following is the query I used in Oracle BI Answers:
CHARINDEX(''ACR'', "Change Requests".Summary)
I got the following error:
State: S1000. Code: 10058. [NQODBC] [SQL_STATE: S1000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <(>: Syntax error [nQSError: 26012] . (S1000) SQL Issued: {call NQSGetQueryColumnInfo('SELECT "Change Requests"."Change Request #", "Change Requests".Summary, CHARINDEX(''ACR'', "Change Requests".Summary) FROM "New DataMart Quality"')}
Can anyone pls suggest me some solution.
_Rishu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Hi Rishu
Try using INSTR. Here's the syntax:
INSTR(string1, string2, [start [, n]])
The function takes a string, string1, and find the first occurence of string2 in that string, returning an integer of the position in string1. The function will optionally begin the search at a given start position and can even return the nth set of string2 in string1. If you omit the start position, the function searches from the beginning of string1. If you provide a negative number for the start position, the function searches backwards from the end of string1.
Here are some examples:
INSTR('San Francisco','an') returns 2
INSTR('San Francisco','an', 1, 2) returns[b] 7 as this is the second occurrence of 'an'
INSTR('San Francisco','an', -1, 2) returns[b] 2 as this is the second occurrence of 'an' when starting from the end
Does this help?
Regards
Michael

Similar Messages

  • How to find combinations of a string

    Hi Dear,
    How can we find the combination of a given string whatever input given by user.
    If the String is A1C the possible outcomes are:
    A1C
    AC1
    1CA
    1AC
    CA1
    C1A
    Best Regards,
    Aditya

    PARAMETERS :
      p_char(12) TYPE c.                   " Input character.
    * Data declarations...................................................*
    * Work variables                                                      *
    DATA :
      w_fact     TYPE i                    " Factorial.
                 VALUE 1,
      w_index    TYPE i,                   " Index.
      w_count    TYPE i,                   " count.
      w_str(40)  TYPE c,                   " String.
      w_str3(40) TYPE c,                   " String.
      w_str2(40) TYPE c,                   " String.
      w_temp     TYPE c,                   " Temporary character.
      w_i        TYPE p,                   " Index outer.
      w_j        TYPE p,                   " Index inner.
      w_flag     TYPE i,                   " Flag variable.
      w_len      TYPE i.                   " Length.
    w_str = p_char.
    w_len = STRLEN( p_char ).
    IF p_char IS INITIAL.
      WRITE 'Enter any string'.
    ELSE.
      IF w_len < 7.
    *Populating w_str and w_str2 with numbers-----------------------------*
        DO w_len TIMES.
          w_index = sy-index - 1.
          w_count = w_len - sy-index.
          w_fact = w_fact * sy-index.
          w_str+w_index(1) = sy-index.
          w_str2+w_count(1) = sy-index.
        ENDDO.                             " DO w_len times.
        w_i = w_str.
        w_j = w_str2.
    *Removing comma and spaces--------------------------------------------*
        WRITE w_i TO w_str3 LEFT-JUSTIFIED.
        TRANSLATE w_str3 USING ', '.
        CONDENSE w_str3 NO-GAPS.
        w_index = 0.
    *While first number is less then last number--------------------------*
        WHILE w_i <= w_j.
          CLEAR w_str2.
          WRITE w_i TO w_str LEFT-JUSTIFIED.
          TRANSLATE w_str USING ', '.
          CONDENSE w_str NO-GAPS.
          DO w_len TIMES.
            w_index = sy-index - 1.
    *If w_str contains only digits from w_str3 then copy that digit into--*
    *w_str2---------------------------------------------------------------*
            IF w_str+w_index(1) CA w_str3.
              w_str2+w_index(1) = w_str+w_index(1).
            ELSE.
    *Else set flag and exit from loop as it is not proper combination-----*
              w_flag = 1.
              EXIT.
            ENDIF.                          " IF w_str+w_index(1) CA w_str3.
          ENDDO.                           " DO w_len TIMES.
    *If flag is zero check for repitation of digits-----------------------*
          IF w_flag = 0.
            DO w_len TIMES.
              w_index = sy-index - 1.
              FIND ALL OCCURRENCES OF w_str3+w_index(1)
                      IN w_str2 MATCH COUNT w_count.
    *If digit repeats set flag and exit from loop-------------------------*
              IF w_count > 1.
                w_flag = 1.
                EXIT.
              ENDIF.                       " IF w_count > 1.
            ENDDO.                         " DO w_len times.
          ENDIF.                           " IF w_flag = 0.
    *If flag is zero then replace digits with corresponding positions of--*
    *real string----------------------------------------------------------*
          IF w_flag = 0.
            DO w_len TIMES.
              w_index = sy-index - 1.
              w_temp = w_str2+w_index(1) - 1.
              w_str2+w_index(1) = p_char+w_temp(1).
            ENDDO.                         " DO w_len TIMES.
            WRITE :/ w_str2.
          ENDIF.                           " IF w_flag = 0.
          w_i = w_i + 1.
          w_flag = 0.
        ENDWHILE.                          " WHILE w_i <= w_j.
        WRITE :
          / 'TOTAL ',
          w_fact,
          ' combinations '.
      ELSE.
        WRITE :/ 'Enter shorter string.'.
      ENDIF.                               " IF w_len < 10.
    ENDIF.                                 " IF p_char IS INITIAL.

  • Newbie question: cannot find symbol symbol: class STRING

    I've just decided to teach myself some java, and on my first try something's going wrong and I don't know what it is.
    I'm currently doing this tutorial: http://java.sun.com/docs/books/tutorial/uiswing/learn/example1.html
    and everything is good until I try to compile it and I get this error in the cmd
    HelloWorldSwing.java:30: cannot find symbol
    cannot find symbol
    symbol: class STRING
    everything has been written verbatim from the tutorial, including "import javax.swing.*;"
    What's wrong with it and how do I fix it?

    Hi,
    I saw the coding that You had given a link in your post. Change the following
        public static void main(String[] args) {bye for now
    sat

  • Query engine : Can not find DSN in Connection String

    DearSir/Madam,
    Opearating System Windows 7 Professional(32-bit).
    I am using Application, which is developed : Visual basic 6.0(32-bit), Report Writer : Crystal Report 9.2.693(32-bit) and database: Oracle 9.2.0.10(32-bit).
    ODBC Data source : System DSN created and Connection established (Based on Driver : CR ORACLE ODBC Driver 4.10 (cror818.dll))
    In windows 7 environment Data Base connectivity and data fetching also wroking fine.
    My problem is while running reports it display error as "Query engine : Can not find DSN in Connection String"
    I want run time reports.
    For your kind information, at the same time in Windows XP Professional there is no problem found and working fine.
    Kindly help me.
    Thanks and regards,
    Swarup

    Crystal Reports 9.x is not supported on Win 7. See the following wiki:
    http://wiki.sdn.sap.com/wiki/x/b4JiAw
    - Ludek

  • Finding longitude and latitude for a given location

    Hi
    I would like to find Longitude and Latitude for a given address.
    Is there any Oracle spatial function available for that?
    Paul

    Oracle does offer built-in geocoding functions, but you would need to purchase data from a POI vendor or create your own data to geocode against. Oracle takes care of parsing human-readable addresses but needs reference data sets to do lookups against in order to return the latitude and longitude amongst other things back to the caller.
    You can get sample data from OTN or possible an Oracle Partner like NAVTEQ to try this out.

  • [Forum FAQ] How to find and replace text strings in the shapes in Excel using Windows PowerShell

    Windows PowerShell is a powerful command tool and we can use it for management and operations. In this article we introduce the detailed steps to use Windows PowerShell to find and replace test string in the
    shapes in Excel Object.
    Since the Excel.Application
    is available for representing the entire Microsoft Excel application, we can invoke the relevant Properties and Methods to help us to
    interact with Excel document.
    The figure below is an excel file:
    Figure 1.
    You can use the PowerShell script below to list the text in the shapes and replace the text string to “text”:
    $text = “text1”,”text2”,”text3”,”text3”
    $Excel 
    = New-Object -ComObject Excel.Application
    $Excel.visible = $true
    $Workbook 
    = $Excel.workbooks.open("d:\shape.xlsx")      
    #Open the excel file
    $Worksheet 
    = $Workbook.Worksheets.Item("shapes")       
    #Open the worksheet named "shapes"
    $shape = $Worksheet.Shapes      
    # Get all the shapes
    $i=0      
    # This number is used to replace the text in sequence as the variable “$text”
    Foreach ($sh in $shape){
    $sh.TextFrame.Characters().text  
    # Get the textbox in the shape
    $sh.TextFrame.Characters().text = 
    $text[$i++]       
    #Change the value of the textbox in the shape one by one
    $WorkBook.Save()              
    #Save workbook in excel
    $WorkBook.Close()             
    #Close workbook in excel
    [void]$excel.quit()           
    #Quit Excel
    Before invoking the methods and properties, we can use the cmdlet “Get-Member” to list the available methods.
    Besides, we can also find the documents about these methods and properties in MSDN:
    Workbook.Worksheets Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff835542(v=office.15).aspx
    Worksheet.Shapes Property:
    http://msdn.microsoft.com/en-us/library/office/ff821817(v=office.15).aspx
    Shape.TextFrame Property:
    http://msdn.microsoft.com/en-us/library/office/ff839162(v=office.15).aspx
    TextFrame.Characters Method (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff195027(v=office.15).aspx
    Characters.Text Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff838596(v=office.15).aspx
    After running the script above, we can see the changes in the figure below:
    Figure 2.
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thank you for the information, but does this thread really need to be stuck to the top of the forum?
    If there must be a sticky, I'd rather see a link to a page on the wiki that has links to all of these ForumFAQ posts.
    EDIT: I see this is no longer stuck to the top of the forum, thank you.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Find and Replace text string in HTML

    Opps... I hope this forum is not just for Outlook. My Html files reside on my hard-drive. I am looking for VBA code to open specified file names ####File.html and then find and replace text strings within the html for example "####Name" replaced
    with "YYYYY"
    I drive the "####File.html" names and the find and replace text strings from an Excel sheet. I am an artist and this Sub would give me time to paint instead of find and replace text. Thank you!
    [email protected]

    Hello Phil,
    The current forum is for developers and Outlook related programming questions. That's why I'd suggest hiring anybody for developing the code for you. You may find freelancers, for example. Try googling for any freelance-related web sites and asking such
    questions there.
    If you decide to develop an Outlook macro on your own, the
    Getting Started with VBA in Outlook 2010 article is a good place to start from.

  • How to get a position in a string?

    I need to get a position in a string like the word CHEESE, where the c is position 1, the h is position 2, the e is position 3 etc... Which input stream should i use and how does it work really?

    indexOf(int ch)
    Returns the index within a string of the first occurrence of the specified character.

  • How to find out the infoProvider for a given dimension table?

    Experts:
    In RSA1, I want to find out the infoProvider for a given dimension table.
    But I am not sure how to display the tables linked to a given infoProvider.
    Could you provide a way to display all tables linked to a given infoProvider?
    Thanks a lot!

    See, The dimension table starts with Dcubename1 and incremental Dcubename2 .... so on
    Ex.ZSD_C01 is your cube name
    Dim tables starts for this is /BIC/DZSD_C011 /BIC/DZSD_C012 ...
    Goto - LISTSCHEMA  - derive cube name from given dim table and enter cube name  - execute - will show you all the tables

  • How to find out if a string is all alphabets

    Hi,
    How can I find out if a string contains all alphabets? Please help. Thanks.

    Hi,
    How can I find out if a string contains all
    all alphabets? Please help. Thanks. I am not sure if there's easier way. But this code should do what you want:
    boolean bAlpha = true;
    for (int i=0; i<str.length; i++)
    if (!Character.isLetter(str.charAt(i))){
    bAlpha = false;
    break;
    //bAlpha is true if str contains only alphabets.

  • How to find out the description for the given field?

    Hi All,
    How to find out the description for the given field?
    I mean ETTYP  Desription is VTEXT. This we can find in TVEPT  Table. So, How canwe find this?
    Thanks in Advance
    Sri...

    Hi  Avi,
    If i want to disply the  fields like   AUART and 'Description of AUART',
    Suppose based on my query i will take AUART from T184 table. And the description of AUART is available in TVAKT table.
    my question is if i have given T184-AUART  and how do u find out AUART Description ?(How do u know which table is having Description of AUART)?
    Thanks in Advance
    Sri...

  • Find out room ID with a given document URL

    Hi, Experts,
    I am new to KM.
    I wanna create an application, which can find out the room ID after given a document URL.
    doc URL short ID e.g.https://abc.com/irj/go/nui/sid/d02704ea-1111-2e10-f0b3-adf62453643d
    room ID e.g. 70823d8e-5d0b-6f10-a222-ec780d200f78
    the given URL will link to a document.
    I need to find out which room stores this document.
    based on the room ID found out, I will know the room admin
    Any idea or suggestions about which API or method I could use? to get the room ID after the doc URL given?
    Thanks a lot!

    Hi, Experts,
    I am new to KM.
    I wanna create an application, which can find out the room ID after given a document URL.
    doc URL short ID e.g.https://abc.com/irj/go/nui/sid/d02704ea-1111-2e10-f0b3-adf62453643d
    room ID e.g. 70823d8e-5d0b-6f10-a222-ec780d200f78
    the given URL will link to a document.
    I need to find out which room stores this document.
    based on the room ID found out, I will know the room admin
    Any idea or suggestions about which API or method I could use? to get the room ID after the doc URL given?
    Thanks a lot!

  • How to find and replace any string between " "

    Hi everyone,
    Here my sample
    String szTest;
    szTest = "Yellow banana";
    szTest = "Blue monkey";
    szTest = "Red mango";
    szTest is only needed when it's in testing progress. Now I want to put all of that in the /*comment*/ so the released program won't run those code any more (but still keep szTest so I can use it for future develop testing).
    So Here what I want after using the Find and Replace Box:
    //String szTest; //Manual
    /*szTest = "Yellow banana";*/ //use find and replace
    /*szTest = "Blue monkey";*/ //use find and replace
    /*szTest = "Red mango";*/ //use find and replace
    I think I can do this with Regular expressions or Wildcards. But I don't know how to find and replace any string between " and ".
    Find: szTest = " ??Any string?? ";
    Replace with: /*szTest = " ??Any string?? ";*/
    Thanks for reading.

    Hi Nathan.j.Smith,
    Based on your issue, I suggest you can try the Joel's suggestion check your issue again. In addition, I find a MSDN document about how to use the Regex.Replace Method to match a regular expression pattern with a specified replacement string,
    maybe you will get some useful message.
    https://msdn.microsoft.com/en-us/library/xwewhkd1(v=vs.110).aspx
    If the above suggestion still could not provide you, could you please tell me what language you use to create the program for finding and replace any string using regular expression so that we will find the correct programming develop forum to support this
    issue?
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Apple mail problem message reads - Account removal failed with error: "The operation couldn't be completed. Unable to find an account for the UID given.".

    Account removal failed with error: “The operation couldn’t be completed. Unable to find an account for the UID given.”.   - trying to remove account but get this message please help

    Try to remove the account in the Internet Accounts preference pane.

  • Is it possible to find a base record for a given component using a SQL qry

    Is it possible to find a base record for a given component through a SQL query ?
    Ex:
    1. VOUCHER for VCHR_EXPRESS
    2. VENDOR for VNDR_ID
    The below query gives multiple rows, I want it to restrict results to just one row
    SELECT DISTINCT A.PNLGRPNAME AS COMPONENT, A.DESCR, A.ADDSRCHRECNAME, A.SEARCHRECNAME, D.RECNAME AS TableName
    FROM PSPNLGRPDEFN A, PSPNLGROUP B, PSPNLDEFN C, PSPNLFIELD D, PSRECDEFN E
    WHERE A.PNLGRPNAME = B.PNLGRPNAME
    AND A.MARKET = B.MARKET
    AND B.PNLNAME = C.PNLNAME
    AND C.PNLNAME = D.PNLNAME
    AND A.PNLGRPNAME = 'VNDR_ID' -- Component Name
    AND E.RECNAME = D.RECNAME
    AND E.RECTYPE =0
    AND D.FIELDUSE =0
    AND D.OCCURSLEVEL = 0
    AND B.HIDDEN = 0
    Thanks in Advance..

    For the given examples, the problem is that there are pages in these components that contain subpages with record names specified. The SubPage field type appears to be at level 0, but if you view the SubPage definition, the records are at level 1. This is because the scroll area is contained within the subpage.
    In theory, the situation is complicated by the fact that you can have subpages within subpages, which would force you to use a recursive query to fully expand the subpages. In practice, there probably aren't many, if any, pages where a scroll area is buried several subpages deep.
    An alternative might be to compare the primary keys of the level 0 records to the primary keys of the add or search record keys. They should only match for the base record. Even this option is not trivial, though.
    Regards,
    Bob

Maybe you are looking for