To validate each part of the string

Hi,
In one string, we have these
ID_A,ID_B,ID_C, ..., ...
I know that there's a way in PL/SQL to divide it into several parts and each part is for one ID. But can I expect that to divide the string into several parts, and then to store all IDs in something like an Array, in PL/SQL? Is this possible, though I know there's no array field type in PL/SQL?
Regards,
huamin

xtender wrote:
You can use my package xt_regexp - http://github.com/xtender/XT_REGEXP
To install execute in this order:     types.sql,     xt_regexp.jsp,     xt_regexp.pck
Example:
with t as (
select 'ID_A,ID_B,ID_C,' str from dual
union all
select 'ID_A,ID_B,ID_C,ID_D' str from dual
select
t.*,
row_number() over (partition by t.str order by t.str) substr_number,
substring.column_value substring
from t,
table(xt_regexp.split(t.str,',')) substring
That's nice, but you may want to benchmark that against an approach that doesn't make a bunch of external calls (for performance)...
with t as
  select 1 as id,'ID_A,ID_B,ID_C' str from dual
    union all
  select 2 as id, 'ID_A,ID_B,ID_C,ID_D' str from dual
select
  t.*,
  regexp_substr (t.str, '[^,]+', 1, s.column_value) as split
from
  t,
  table( cast (multiset (select level from dual connect by level <= length(regexp_replace(t.str, '[^,]+'))  + 1) as sys.odcinumberlist)) s
     ID STR                 SPLIT
      1 ID_A,ID_B,ID_C      ID_A
      1 ID_A,ID_B,ID_C      ID_B
      1 ID_A,ID_B,ID_C      ID_C
      2 ID_A,ID_B,ID_C,ID_D ID_A
      2 ID_A,ID_B,ID_C,ID_D ID_B
      2 ID_A,ID_B,ID_C,ID_D ID_C
      2 ID_A,ID_B,ID_C,ID_D ID_D
7 rows selected.
Elapsed: 00:00:00.02
TUBBY_TUBBZ?For example.

Similar Messages

  • Converting part of the string to a date and subtract with sysdate.

    HINT! In order solve this you must know how the pnr is assembled. Study this:
    650323-5510, we only need the first six characters. They inform us about when the person (car owner) was born. In this case it is 23 Mars 1965. You have to use several oracle built-in-functions to solve this. Hint! Begin by converting part of the string to a date and subtract with sysdate.
    select to_char(to_date(cast(pnr,'YYMMDDMM'))) from car_owner;
    please what am i doing wrong. i need the result to be something like this
    Hans, Rosenboll, 59,6 years.

    Hi.
    The main problem here is you have only last two digits of year. That could be the problem in a couple of years from now, when somebody born after 2k would get in to your database. For now if we ignore this problem the right solution would be :
    <code>
    SELECT months_between(trunc(SYSDATE),
    to_date('19' || substr('650323-5510',
    1,
    6),
    'YYYYMMDD')) / 12 years_old
    FROM dual
    </code>
    Suppose you are expecting the age of the car owner as a result above code will give you that. One again notice the '19' I appended.
    Best regards.

  • Display each words of the string in separate line.

    Dear Javaties,
    pls help me creating this program.
    Display each words of the string in separate line.
    Eg.
    Input value : Testing this string.
    Output : Testing
    this
    string
    Thanks in adavance,
    M. Suresh

    M Suresh,
    We would be delighted to help if only you asked a specific question. Do my work for me is not a specific question.
    The Javaties

  • Addressing of part of the string in the container

    Hello,
    in a mail task I would like to print only some characters from a string - e.g. from second to tenth - is it possible to address some part of the string in the container as is usual in abap?
    thx,
    JJ

    Hi,
    Yes , it is possible. If you want to show only some part of the string value in mail description you can use normal abap string operations. For example: In Mail description if you want to show only a part variable VALUE. you can just use &VALUE+a(b)&. It will work !!
    You can try it out !!
    Regards
    Krishna Mohan

  • Using INSTR to extract part of the string ?

    Morning guys and Happy Friday.
    I have a situation where I have to pull out part of the string using a select statement.
    Here is the string and I have to get the contents between the 2nd and 3rd backslash. So, basically, I have to extract marypoppins. Any ideas ?
    C:\USERS\marypoppins\Docs\SpecificationHere is where I started ... and I have stumbled upon trying to find the 3rd backslash. I can easily start the INSTR at 4 because I know that it will always be 'C:\'
    select select substr(C:\USERS\marypoppins\Docs\Specification',
                                INSTRB('C:\USERS\marypoppins\Docs\Specification', '\', 4), .....) from dual;

    Additionally you can break it all up simply with regular expressions..
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'C:\USERS\marypoppins\Docs\Specification' as txt from dual)
      2  -- END OF TEST DATA
      3  select rownum, regexp_substr(txt, '[^\]+',1,rownum) as element
      4  from t
      5* connect by rownum <= length(regexp_replace(txt,'[^\]'))+1
    SQL> /
        ROWNUM ELEMENT
             1 C:
             2 USERS
             3 marypoppins
             4 Docs
             5 Specification
    SQL>

  • Display only part of the STRING field, but search ALL field

    Hi all,
    I have a field VARCHAR2(4000) that holds a lot of text.
    When I make a report in APEX, it shows in each row, ALL text, so the report is very "ugly".
    I want to limit the display of that column for only the first 60 characters.
    I tried to use the SUBSTR function, that worked, but the search option will search for the text only in that 60 lenght characters, and will now search in the rest (not displayed) part of the field.
    Is there a way to do this full search and display only part of the field?
    Thanks

    You can have the 'substring' column displayed to the user, but have another column which shows the full text lets say it has an ALIAS of "*SEARCH_LARGE_TEXT*" in the report definition(and is among the displayed columns).
    You can hide the large text column(SEARCH_LARGE_TEXT) using JS as
    $('th[id="SEARCH_LARGE_TEXT"],TD[headers^="SEARCH_LARGE_TEXT"]').hide()
    Note: ^= syntax used to match data column even when break formatting used
    You can make sure that the column stays hidden even after an IR filter or refresh by binding it to the refresh event of the IR by
    $('#apexir_WORKSHEET_REGION').bind('apexafterrefresh', function(){ 
      $('th[id="SEARCH_LARGE_TEXT"],TD[headers^="SEARCH_LARGE_TEXT"]').hide()
    change the string "SEARCH_LARGE_TEXT" with your column's alias
    Hope it helps

  • Get a part of the string

    Hi SAP gurus 
    i have a string where i need to eliminate 'A.B.N' from the following string please advice
    as i am new to xslt i am not sure how
    xsl:value-of select="concat('A.B.N. ',$vABNNameValue)"/
    this is the part of the xsl i am trying to change the above statement in .
    :for-each select="/ORDERS02/IDOC/E1EDKA1" >
                                        <xsl:if test="PARVW = 'LF' ">
                                            <Name3>
                                                <xsl:variable name= "vABNNameValue">
                                                     <xsl:value-of select="''" />
                                                     <xsl:for-each select="E1EDKA3" >
                                                        < xsl:if test="QUALP = 'ABN' ">
                                                            <xsl:if test="STDPN != ''">
                                                                 <xsl:value-of select= "STDPN"/>
                                                             </xsl:if>
                                                         </xsl:if>
                                                     </xsl:for-each>
                                                 </xsl:variable>
                                                 <xsl:choose>
                                                     <xsl:when test= "$vABNNameValue != ''">
                                                        < !xsl:value-of select="concat('A.B.N. ',$vABNNameValue)"/-!>
                                                        <xsl:value-of select="concat(' A.B.N. ',$vABNNameValue)"/>
                                                        <!<xsl:value-of select="$vABNvalue"/>>
                                                    </xsl:when >
                                                    <xsl:otherwise >
                                                        <!-- OVSD Call 324728 End -- >
                                                        < xsl:variable name="Name3Test">
                                                            <xsl:call-template name="Template_GetE1EDKA1Name3">
                                                                 <xsl:with-param name= "TestValue">LF</xsl:with-param >
                                                            < /xsl:call-template>
                                                        < /xsl:variable>
                                                        < xsl:if test="$Name3Test != ''" >
                                                            <xsl:value-of select="$Name3Test"/ >
                                                        </xsl:if >
                                                        <!-- OVSD Call 324728 Begin -- >
                                                    < /xsl:otherwise>
                                                < /xsl:choose>
                                            < /Name3>
                                        < /xsl:if>
                                    < /xsl:for-eac
    please advice its so urgent i have a production issue
    i know there is a function substring
    thanks

    Have a look at this
    http://www.w3schools.com/xpath/xpath_functions.asp#string
    i guess this might be useful to you :
    <b>replace(string,pattern,replace)       </b>
    Returns a string that is created by replacing the given pattern with the replace argument
    Example: replace("Bella Italia", "l", "")
    Result: 'Bea Itaia'
    in your case
    <b>replace("someA.B.Nssss","A.B.N","")</b>
    I think it would work. try this....
    PS: award points if answer helps you.
    thanks,
    Pooja

  • How Can I extract each part of a string ??

    Dear Sir:
    I have a string like following to connect to Oracle Database:
    JDBC_URL= jdbc:oracle:thin:@localhost:1521:ABChere,
    I have Variables like:
    driverClass="";
    Hostname = "";
    port = "";
    SID="";
    etc
    I try to extract each part from this JDBC_URL,
    then assign them to following variable separately:
    driverClass="jdbc:oracle:thin";
    Hostname = "localhost";
    port = "1521";
    SID="ABC";
    Can some guru help give some good example and show how to do it??
    Thanks and have a nice weekends.

    try using a regular expression (regex).
    here, i am going to try to freeball it:
    // JDBC_URL= jdbc:oracle:thin:@localhost:1521:ABC
    Pattern p = Pattern.compile("(JDBC_URL)(\\s*)(=)(\\s*)(.*?:.*?:.*?)(:)(@)(.*?)(:)(.*?)(:)(.*?)")
    Matcher m = p.matcher(text)
    if(m.matches()) or if(m.lookingAt()){
    String driverclass = m.group(5);
    String hostname = m.group(8);
    ...group(10);
    ...group(12);
    }note that (\\s*) means "any amount of whitespace" and (.*?) means "any amount of any character (reluctantly)".
    i used that because i dont know the constraints on those values. for only numbers you can use (\\d+) etc
    [http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html|http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html]
    also, i put everything into ( ) - which is called a capture group - but that was just to make it clearer. in your final regex you may get
    rid of most of those.

  • I'm going a project with a character that has a quote inside. I outlined each part of the character that needs color. How do i color whats inside my path? and not whats on the outside of the outline?

    I have this project where i have outlined my character and have a quote inside. I outlined the hair and arms and part that will be needing color. But I'm not sure how to color the words on the inside of the outlined parts without it affecting the letters that overlap.

    I'm trying to follow your description. Can you provide a screen capture?
    A normal workflow is to organize elements in groups and layers. You can assign multiple attributes to any of these "Objects" using the "Appearance" panel. Move the attributes, such as fills and strokes, up or down the Appearance list as needed. Try separating your elements in this way. Target a group or layer by clicking the round button to its right, in the Layers panel and add additional fill, stroke, or effect attributes from the Appearance Panel Flyout Menu.

  • Update part of the string

    Hello,
    please, I have million of records and I need to replace LAST THREE characters, regardless of what they are,  in column that is always of the same length e.g.,1234abc need to be:
    1234000
    i.e., to keep first four characters!
    thanks

    Hi,
      If your column data type is of datatype varchar(max) or nvarchar(max)
      you can use the WRITE clause in the UPDATE statment
    DROP TABLE tblupdatewrite
    CREATE TABLE tblupdatewrite
    c1 VARCHAR(MAX)
    INSERT INTO tblupdatewrite
    SELECT '12345abc'
    UPDATE tblupdatewrite
    SET C1.WRITE('000',LEN(C1)-3,3)
    SELECT * FROM tblupdatewrite
    Best Regards Sorna

  • Variable for restriction based on part of the String

    Hello Experts,
    I have a characteristic named Product Hierarchy (0PRODHIER) in the query. I want to create a variable so that the report displays the results based on the first character of 0PRODHIER.  How can this be achieved?
    Thanks,
    Rishi

    Hi Mayank
    Thanks for your response. I knew that we can do this at the Cube level but I was just wondering if there is any other way to achieve this at the BEx level.
    Thanks
    Rishi

  • Delete part of a string question

    Hello I have this String 12a
    I need to get a the value 12 of it an make it an int
    But the problem is that I don't know what the string is it can be
    12
    or 12 a
    or 12a
    It is for people to fill in there house address and this is the number part.
    The string is like this String number ="\"12a\"";
    Is it possible to look for a letter in a String and delete it if you only want ints???

    Try this on the command line. Dealing with java.lang.NumberFormatException in cases where the number is too large is left as an exercise.
    Harald.
    import java.util.regex.*;
    * demonstrates use of <code>java.util.regex</code> to check if a
    * string starts with digits.
    public class bla {
       * thrown by {@link #getNumber} if the given string does not start
       * with digits.
      private static class BoomBoom extends Exception {
        public BoomBoom(String msg) {super(msg);}
       * reusable pattern to check for digits.
      private static Pattern p = Pattern.compile("[0-9]+");
       * convert leading digits of the parameter to an <code>int</code>
       * and return it.
       * @throws BoomBoom if the parameter does not start with digits.
      public static int getNumber(String s) throws BoomBoom {
        Matcher m = p.matcher(s);
        if( !m.lookingAt() ) {
          throw new BoomBoom("The string `"+s+"' does not start with "
                    +"a positive number.");
        return Integer.parseInt(m.group(0));
      // don't clutter the javadoc
      private bla() {}
       * passes each command line argument through {@link #getNumber} and
       * prints the output or error to <code>System.out</code> or
       * <code>System.err</code> respectively.
      public static void main(String[] argv) {
        for(int i=0; i<argv.length; i++) {
          try {
         System.out.println("Your string `"+argv[i]
                      +"' starts with number "
                      +getNumber(argv));
    } catch( BoomBoom e ) {
         System.err.println(e.getMessage());

  • Remove some portion of the String

    Hi,
    My problem is String contains data is
    artist1
    title1
    -1
    artist2
    title2
    2
    artist3
    title3
    -1
    artist4
    title4
    2
    i want to remove some portion of the string like artist2, title2, 2 so my updated string should be like
    artist1
    title1
    -1
    artist3
    title3
    -1
    artist4
    title4
    2
    Here i am using String.replaceAll("artist2","");
    String.replaceAll("title3","");
    String.replaceAll("2","")("[\code]
    its deleting whole data in a string, can any one please help me how to delete particular part of the string. Here artist and title are unique and no are reapeated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hey I had the same problem like you yesterday.
    I tried using regEx with positiv lookahead but noticed that there was a problem when the String went over multiple lines. There is probably some solution to it that i havent found yet.
    So what I did was get the Index of the first text I wanted deleted(in your case I guess "artist2"). Then got the Index of the end of the deletion point(In your case the "2"?) and then formed a new String with the substring from the orginal one and the indexes of the two deletion points.
    Sounds kinda dirty but it did work out. Anyway I'll dig myself into regular expressions more today because if you get them to work, they're a charm :)

  • Recording Audio Cuts off the first part of the region?

    Hi. When i record audio the regions show up after recording and i have to pull the beginning of the region back a bit so that i can see the full length of the audio recording. Its non destructive but very annyoing. How can i stop it doing this everytime? Thanks

    Thanks Mike for replying
    But the thing is; I want to perform a computation process on the list manager values to trim off the first part of the string. I have the dynamic lov for list manager. But when I insert/update list manager item values I don't want the first part of string in the database.
    Please help with the function. i was trying the below function but it doesn't work; errors out saying
    ORA-06550: line 16, column 14: PLS-00597: expression 'V_ARRAY_1' in the INTO list is of wrong type ORA-06550: line 17, column 9: PL/SQL: ORA-00904: : invalid identifier ORA-06550: line 15, column 7: PL/SQL: SQL Statement ignored
    {code}
    DECLARE
       v_array          apex_application_global.vc_arr2;
       v_array_1         apex_application_global.vc_arr2;
       v_string         VARCHAR2 (32767);
       BEGIN
       -- Convert delimited string to array
       v_array :=
          APEX_UTIL.
           string_to_table (:P3_LM_USES);
       FOR i IN 1 .. v_array.COUNT
       LOOP
          SELECT LTRIM (SUBSTR (v_array (i), INSTR (v_array (i), '..') + 2))
            INTO v_array_1
            FROM DUAL;
    v_string := HTMLDB_UTIL.table_to_string(v_array_1,':');
    apex_application.g_print_success_message := apex_application.g_print_success_message || v_string;
             END LOOP;
    RETURN (v_string);
    END;
    {code}
    Thanks,
    Orton

  • How to replace part of a String with another String :s ?

    Got a String
    " Team_1/Team_2/Team_3/ "
    And I want to be able to rename part of the string (they are seperated by '/'), for example I want to rename "Team_3" to "Team C", and "Team_1" to "Team A" while retaining the '/' character how would I do this?
    I have tried using String.replace(oldValue, newValue); but this doesnt work, any ideas?

    What do you mean that it doesn't work? You do know that the method returns the modified string? The actual string that you invoke the method on is not altered.
    /Kaj

Maybe you are looking for