Split string, delimiter based

I searched these forumns and I can't find an Oracle function that splits a string into several columns according to a delimiter. I've seen some functions or procedures, but I ws wonder if there is a function of standard Oracle.

data: 44444-123413

I just want everything before the ' - '.

44444


Thank you!

Hello

Welcome to the forum!

To get the front part of the (first) '-'

REGEXP_SUBSTR ( txt
           , '^[^-]*'
           )

What do you want if txt starts by '-'? The above expression return the NULL value.
What do you want so txt does not contain '-'? The above expression returns all txt.

[This thread | http://forums.oracle.com/forums/thread.jspa?threadID=945432&tstart=0] addresses the more general case of your question.

Tags: Database

Similar Questions

  • Reg: Split string

    Dear all,

    Oracle Database 11g R2 11.2.0.1 SE1

    Consider the string

    Madhu, no. 34 Church street, main road, TMK

    I need to trim the string based on the conditions below.

    Condition 1: Split string 35 characters each

    Condition 2: Search until the previous by commas and visualize up to comma.

    Condition 3: split to then 35 characters.

    Power required for the highest chain

    Addr1 Addr2
    Madhu, no. 34 Church streetmain road, TMK

    Comment:

    Condition 1: Addr1-> 35 char = Madhu, no. 34 Church street, main ro

    Condition 2: Addr1-> comma previous search-> out-> Madhu, no. 34 Church street

    Condition 3: Addr2-> search for then 35 characters (i.e. "main road")-> 1-> Condition 2 Condition

    Please help in this regard.

    What's easier:

    with t
    as
    (
    select 'Madhu, No 34 Church street, main road, TMK' addr
      from dual
    )
    select substr(addr, 1, instr(addr, ',', -(length(addr) -35)) - 1) addr1,
          substr(addr, instr(addr, ',', -(length(addr) -35)) + 1, 35) addr2
    from t
    
  • Query SQL to split the lines based on the amount

    I have the data in the following format in the table.

    ORDER_ID PRODUCT_ID QUANTITY

    O1 A1   3

    I need to write the sql query to divide the data in following format:

    ORDER_ID PRODUCT_ID QUANTITY

    O1 A1   1

    O1 A1   1

    O1 A1   1

    Query must split the data based on the value in the quantity column.

    Thank you

    Developer

    Hello

    create table order_items (
      order_id varchar2(2),
      product_id varchar2(2),
      quantity number
    )
    ;
    insert into order_items values ('O1', 'A1', 3)
    ;
    -- Recursive Subquery Factoring
    with item(order_id, product_id, quantity) as (
      select
        order_id, product_id, quantity
      from order_items
      union all
      select
        order_id, product_id, quantity - 1
      from item
      where quantity > 1
    )
    select
      order_id, product_id, 1 quantity
    from item
    order by order_id
    ;
    drop table order_items purge
    ;
    
    Table ORDER_ITEMS created.
    
    1 row inserted.
    
    OR PR   QUANTITY
    -- -- ----------
    O1 A1          1
    O1 A1          1
    O1 A1          1
    
    Table ORDER_ITEMS dropped.
    
  • How to split strings?

    Hello

    I'm using action made by Christophe (http://www.vcoteam.info/learn-vco/code-snippets-cancel-one-of-your-running-workflows.html) in order to cancel some workflows.

    Since the selection for tokens window does not display the parameters of the token, I created another entry for my workflow that is supposed to contain the name of the virtual machine, only for infomational purposes.

    I created an action to do this. When I use just "return myWorkflowToken.getInputParameters ();" then all settings are written to the input box.

    In my case, it looks like this:

    {ram = 3000.0, date = Mon Jan 24 16:25:16 THIS 2011, vm = < @id = FinderResult' VC:VirtualMachine/si0vm271/vm - 852' @name = "si0vm562" >, UC = 3.0}

    Since I need only the name of the virtual machine, in this case the part after @name (si0vm562), I need to retrieve it somehow off the chain.

    In the Orchestrator API, I found the String class with the method 'split '.

    At first, I tried to split the string into two parts using this code:

    var params_s = myWorkflowToken.getInputParameters ();
    var params_a_s = params_s.split ("name");
    return params_a_s [1];

    But when I run the workflow, the input dialogue tells me that the "split" function cannot be found.

    How can I retrieve the VM name on the report of a running workflow?

    Thank you

    Concerning

    Andreas

    Hi Andreas,

    I don't think that splitting strings works for your case.

    In fact workflowToken.getInputParameters () does not return a string. It is ch.dunes.scripting.jsmodel.JSProperties instead (you can check this of the Orchestrator client tools-> API Explorer). The split function is not found on the params_s variable.

    In order to achieve your goal, you can try the following:

    get the vm parameter

    Use the parameter name. This is the vm used according to the result of your message

    VM var = workflowToken.getInputParameters () .get ("vm");

    You can check for safety if the virtual machine is defined, except that the virtual machine is the required parameter

    If (vm! = null) {}

    return vm.name

    }

    The code snippet above you should return the value set for the parameter of the virtual machine.

    Hope this helps,

    Martin Marinov

  • Split comma delimited string CONNECT BY Clause

    Hello
    I had a problem by dividing a strings separated by commas into lines.

    I explain the following use cases:

    I have an x in table
    -> create table x (id number, int_status varchar2 (100), c_ref varchar2 (30), s_ref varchar2 (30));

    I inserted values in the table:

    insert into x (id, int_status, c_ref, s_ref) values (1, 'a1, a2, a3, a4 ', 'A',' AS');
    insert into x (id, int_status, c_ref, s_ref) values (1,'b1, b2, b3, b4 ',' B', 'BS');
    insert into x (id, int_status, c_ref, s_ref) values (1,'c1, c2, c3, c4 ", 'C', null);
    insert into x (id, int_status, cust_ref, site_ref) values (1, NULL, would be ', NULL);


    I need to split the int_status separated by commas into individual lines. This means that my result is:

    . What I need or are looking as expected result:
    -----------
    1, has, HAVE, a1
    1, has, HAVE, a2
    1, has, HAVE, a3
    1, has, HAVE, a4
    1, B, BS, b1
    1, B, BS, b2
    1, B, BS, b3
    1, B, BS, b4
    C, 1, null, c1
    C, 1, null, c2
    C, 1, null, c3
    C, 1, null, c4

    I currently have a solution using Regex. But this solution uses the UNIQUE keyword.

    The solution that I currently have:

    Select UNIQUE c_ref, s_ref, regexp_substr (int_status, "[^,] +', 1, level") error_code
    x
    connect regexp_substr (int_status, "[^,] +', 1, level") is not null;


    I need a better solution. Pointers?

    Thank you
    Cherif

    Hi Omar,.

    I mentioned the solution of Odie for similar problem some time ago...
    and in my opinion the easiest to solve your task would be:

    SELECT id,c_ref,s_ref,str error_code
      FROM x_imp,
           XMLTABLE ('ora:tokenize($v, ",")'
                     PASSING int_status AS "v"
                     COLUMNS str VARCHAR2 (12) PATH '.');
    

    output:

    ID     C_REF     S_REF     ERROR_CODE
    1     A     AS     a1
    1     A     AS     a2
    1     A     AS     a3
    1     A     AS     a4
    1     B     BS     b1
    1     B     BS     b2
    1     B     BS     b3
    1     B     BS     b4
    1     C          c1
    1     C          c2
    1     C          c3
    1     C          c4
    

    See you soon,.
    Manik.

  • Split string on the new line

    G ' Day,.

    I am writing a process that takes as input a multiline string. I need to chop this string through line breaks and iterate over each of them, but I can not work how to split a string based on the line breaks and TEO reference Guide is sufficiently vague as to what special characters (if any), you can split a string on.

    This process is intended to be launched directly via TEOWebConsole at this point else I would implement it in CCP instead.

    Thoughts?

    You can use the regular expression ^. * $

    and then feed in the chain and the loop and then through it, cut the ends and go from there.

    I have a TAP of some commonly used functions that I use in many of my automation. I call the function automation tools. I downloaded the zipped here tap. Download, unzip and import.

    It has a function called multiline convert to single-line string. While that might not be exactly what you're doing, you can remove the pieces of the rupture in the line break and be ok I think.

    Here is a screenshot of what I mean:

    -shaun

  • SQL: REGEXP_SUBSTR CSV with string delimiter

    Hello

    I would like to create a function to split a CSV file with string using REGEXP delimiter.

    Because the REGEXP function does not deal with NULL values, in the first place, I use a REGEXP_REPLACE:

    SELECT REGEXP_REPLACE (' ' ' ';) "2011-12-30 15:33:15 '; "" 116 "; » « ; » 1 » ; "" ANSWER "; "" SIP/SDX20016-b6ec9c10 '; (""', '("") + ',' 'NULL' ') FROM dual;

    Result:

    'NULL '; "2011-12-30 15:33:15 '; "" 116 "; "' NULL '; » 1 » ; "" ANSWER "; "" SIP/SDX20016-b6ec9c10 '; "' NULL '.

    If I can deal with the empty columns.

    Then I apply this REGEXP:

    SELECT REGEXP_SUBSTR (' 'NULL';) "2011-12-30 15:33:15 '; "" 116 "; "' NULL '; » 1 » ; "" ANSWER "; "" SIP/SDX20016-b6ec9c10 '; ("' NULL ' ',' [^(";")] +', 1, level)-LOOSE COLLECTION ltab_SplittedTelList
    OF the double
    CONNECT REGEXP_SUBSTR (' 'NULL';) "2011-12-30 15:33:15 '; "" 116 "; "' NULL '; » 1 » ; "" ANSWER "; "" SIP/SDX20016-b6ec9c10 '; » NULL » ', ' [^ « ; »] +', 1, level) IS NOT NULL;

    Result:

    NULL VALUE

    2011-12-30 15:33:15

    116

    NULL VALUE

    1

    REPLIED

    SIP/SDX20016-b6ec9c10

    NULL VALUE

    Very good, but if I put a delimiter column ';' in the middle of a string, for example in the middle of the date, I had my date cut in two.

    I can't find the correct model for my REGEXP.

    Jump, it is possible to do it with REGEXP.

    Thanks in advance,

    Greg.

    Hi, Greg.

    Here's a way to do it in pure SQL:

    WITH got_str AS

    (

    SELECT "' ';'" 2011 12-30; 15:33:15 '; 116. " » « ; » 1 » ; "" ANSWER "; "" SIP/SDX20016-b6ec9c10 '; ' ' ' ' ' AS str

    OF the double

    )

    SELECT THE LEVEL

    , REGEXP_SUBSTR (' ";' |") Str | ';"'

    , '";" ((([^"]*"[^;]) *[^"])*)'

    1

    LEVEL

    NULL

    1

    ) AS sub_str

    OF got_str

    CONNECT BY LEVEL<= 1="" +="" regexp_count="" (="">

    , '";"'

    )

    ;

    Note that I added one; after 2011-12-30.

    Output:

    LEVEL SUB_STR

    ---------- -------------------------

    1

    2 on 12-30-2011; 15:33:15

    3 116

    4

    5 1

    6 ANSWERED

    7 SIP/SDX20016-b6ec9c10

    8

    As always, the solution depends on your version.  It works in Oracle 11.2.

    Your message, it seems that you do this in PL/SQL.  The above query will work in PL/SQL, of course, but it might be simpler to use the code of procedure.  Parse the string from left to right, followed the quotation marks and semicolons.  If you find a semicolon, and the total number of quotes spent so far is the same, then you have found the beginning of a new secondary channel.

  • "Scaling of epizootic ulcerative syndrome and build the waveform (slna)" and "table of string in string delimited a comma."

    I'm taking a picture of waveforms and the units of the scale accordingly.  I have a picture of the sensitivities that the user can change and do this in my "EUs Scaling" under VI.  I would use just of "LAS scale voltage to EU VI LabView", but the sensitivity of my sensors will vary depending on the way through.  I can't much the back wave of construction. I think I'm scaling of values of y in my sub VI correctly.  The sub VI is inside a loop of acquisition data and after reading MX DAQ.  The sub VI is "Scaling had 32ch".

    In addition, when you use DAQ MX create channel he wants to channel names to a string of nouns that are delimited by commas.  How do I take a string array and comma delimit them into one string?

    They are here in 2009.

  • An empty array to a worksheet string, delimiter

    The string table worksheet function does not accept an empty delimiter, it uses the tab character in such a case.

    The same is true for string array spreadsheet function (but of course this function can not work without a delimiter).

    I would appreciate one of the following options:

    • to allow a blank separator for the two functions (for string in array of spreadsheet that can easily obviously works for the worksheet to an array of strings, you might see a delimiter of empty string between each two adjacent characters similar to the function search and the string to replace with an empty search string);
    • to document this behavior correctly;

    I prefer the first espacially option for the string table worksheet function. What do you think?

    aschipfl wrote:

    The string table worksheet function does not accept an empty delimiter, it uses the tab character in such a case.

    It is an old story covered in my idea here. (as of 2009!)

    If there is more insight, it should be added as a comment to the idea of city.

    Let's keep the discussion all in one place! Thank you.

  • Split string

    Dear Sir

    Is there a simple function like string.split

    I want to just split this string 384; 603; 107; 38

    Rgds

    Nadir

    and this thread can also help you:

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-split-a-string-in-to-a-string-array-w...

  • Publish in displaying selectOrderShuttle values selected in a long string delimited by semicolons

    Jdev 11.1.2.2.0

    Hello

    I have a strange problem in selectOrderShuttle.  The Shuttle displays a read-only long text delimited by semicolons instead of each individual value in shuttle.  Example:

    Description; Parent site; Run the approval; Task status code; Comments

    Whereas "assignment is the selectOrderShuttle label and Description; Parent site; Run the approval; Task status code; The comments are the values.

    I expect to see these values like this shuttle:

    Description

    Parent site

    Run the approval

    Task status code

    Comments

    Here is my code snipplet:

    in jspx:

    < af:selectOrderShuttle label = "assignment."

    ID = "sos1" reorderOnly = "false".

    value = "#{pageFlowScope.paramAssignBean.selectedSortValues} '"

    trailingHeader = "Hello World Values.

    readOnly = "false".

    Disabled = "false" size = "300" >

    < f: selectItems value = "#{pageFlowScope.paramAssignBean.allSortItems}" id = "si2" / > "

    < / af:selectOrderShuttle >

    paramAssignBean Java:

    private static final String EVENT_PARAM_ASSIGNS_VO = "ItasEventParamAssignsVO1";

    public list getSelectedSortValues() {}

    log.info ("ENTER getSelectedSortValues");

    String selectedValuesValueAttrName = "AssignmentUid";

    ItasAppModuleImpl am = (ItasAppModuleImpl) ADFUtils.getApplicationModuleForDataControl (this.) ROOT_AM);

    selectedSortValues =

    DataUtils.getAttributeList (am, EVENT_PARAM_ASSIGNS_VO, selectedValuesValueAttrName, null);

    log.info ("END getSelectedSortValues");

    Return selectedSortValues;

    }

    public list getAllSortItems() {}

    log.fine ("ENTER getAllItems");

    String allItemsValueAttrName = "AssignmentUid";

    String allItemsDisplayAttrName = "DisplayLabel";

    ItasAppModuleImpl am = (ItasAppModuleImpl) ADFUtils.getApplicationModuleForDataControl (this.) ROOT_AM);

    allSortItems =

    DataUtils.getGenericChoiceList (am, EVENT_PARAM_ASSIGNS_VO, allItemsDisplayAttrName, allItemsValueAttrName, false, null);

    log.fine ("the END getAllItems");

    Return allSortItems;

    }

    in DataUtils.java

    public static list < SelectItem > getGenericChoiceList (am ApplicationModuleImpl, String voName, String textAttribute, String valueAttribute, boolean addNullEntry, String whereClause) {}

    LOGGER.info ("entering getGenericChoiceList, VO =" + voName + "whereClause:" + whereClause);

    The choiceList list = new ArrayList();

    try {}

    ViewObject vo = am.findViewObject (voName);

    vo.setWhereClause (null);

    If (null! = whereClause) {}

    vo.setWhereClause (whereClause);

    }

    LOGGER.info ("vo.getQuery:" + vo.getQuery ());

    vo.executeQuery ();

    vo.setRangeSize(-1);

    SelectItem TR;

    If {(addNullEntry)

    TR = new SelectItem ("", "");

    choiceList.add (si);  Add an empty entry at the top of the list

    }

    Rank [] lookupRows = vo.getAllRowsInRange ();

    LOGGER.info ("choiceList.length:" + lookupRows.length);

    for (int j = 0; j < lookupRows.length; j ++) {}

    TR = new SelectItem (lookupRows [j] .getAttribute (valueAttribute), (String) lookupRows [j] .getAttribute (textAttribute));

    choiceList.add (si);

    }

    If (null! = whereClause) {}

    vo.setWhereClause (null);

    }

    } catch (Exception e) {}

    e.printStackTrace ();

    LOGGER.severe ("error in getGenericChoiceList():" + try ());

    throw new oracle.jbo.JboException (e);

    }

    choiceList return;

    }

    public static list getAttributeList (ApplicationModuleImpl, String voName, String valueAttribute, String whereClause am) {}

    LOGGER.info ("enter getAttributeList (, VO =" + voName + "whereClause:"+ whereClause); ")

    The choiceList list = new ArrayList();

    try {}

    ViewObject vo = am.findViewObject (voName);

    vo.setWhereClause (null);

    If (null! = whereClause) {}

    vo.setWhereClause (whereClause);

    }

    LOGGER.info ("vo.getQuery:" + vo.getQuery ());

    vo.executeQuery ();

    vo.setRangeSize(-1);

    Rank [] lookupRows = vo.getAllRowsInRange ();

    LOGGER.info ("attributeList.length:" + lookupRows.length);

    LOGGER.info ("Mina Mina valueAttribute:" + valueAttribute);

    for (int j = 0; j < lookupRows.length; j ++) {}

    LOGGER.info ("Mina Mina value:" + lookupRows [j] .getAttribute (valueAttribute));

    choiceList.add (lookupRows [j] .getAttribute (valueAttribute));

    }

    If (null! = whereClause) {}

    vo.setWhereClause (null);

    }

    } catch (Exception e) {}

    e.printStackTrace ();

    LOGGER.severe ("error in getAttributeeList():" + try ());

    throw new oracle.jbo.JboException (e);

    }

    choiceList return;

    }

    Any ideas?  Help, please.

    Thank you

    -Mina

    Is allSortItems a bean with a Get accessor, but no Set accessor? What is the type of allSortItems?

  • Split string values

    Hello

    I have a column in a table that contains a string separated by.

    for example

    IT. MATERIAL
    IT. APPS
    HE SOFTWARE

    I want to split the two out on two columns for example values

    Column1 - IT
    Column2 - Hardware
    etc.

    Can anyone help?

    Thank you

    Hello

    Here's one way:

    SELECT       SUBSTR ( str
                 , 1
               , INSTR (str, '.') - 1
               )         AS column1
    ,       SUBSTR ( str
                 , INSTR (str, '.') + 1
               )         AS column2
    FROM      table_x
    ;
    

    You might also achieve the same results using REGEXP_SUBTR, without nested funcitons, but it would be less effective.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data. Examples of special cases, you have to manage, usch as strings with 2 or more '.'s, or without any strings "." s at all.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • Separation of string delimited by tabs

    Hello

    I want to separate a delimited by tab characters in a query field. It consists of three names, and I have to put each of these 3 names in a separate field. How can this be accomplished?

    Example:
    in field 1, we have the string 'John Anderson Smith '.
    in field 2 filed 4 I want to see the following values:
    area 2: John
    field 3: Anderson
    field 4: Smith

    It must be done with a lot of names having different lengths.
    SQL> ed
    Wrote file afiedt.buf
    
      1  select regexp_substr(txt,'\w+' , 1, 1) as nm1
      2  ,regexp_substr(txt, '\w+', 1, 2) as nm2
      3  ,regexp_substr(txt, '\w+', 1, 3) as nm3
      4  ,txt
      5* from t
    SQL> /
    
    NM1              NM2           NM3              TXT
    ------------------- ------------------- ------------------- -------------------
    John              Anderson          Smith              John Anderson Smith
    
    SQL> 
    
  • Need help to split string

    Hi, I would like to know how one can divide the string, where start with capital letters.

    Example, if one have the name and first name: JamesLord, I'd like to split the name James of the Lord

    May be something like below for your entry,

    SELECT REGEXP_SUBSTR('JamesLord','[A-Z][a-z]+') FROM dual
    

    Thank you
    Sunil

  • Lively table consist of Split String?

    I have a question; is it possible to animate a table that contains a string of split? I added the channel in a dynamically done textfield, and I try to figure out how to have each letter will appear one by one, creating the effect of typing and acceleration towards the end... thanks a lot for all the help in advance.

    SerializableAttribute public class InfoPage extends AbstractPage {}

    private var _info:TextField;
    private var _infoText:String = "Lorem ipsum dolor sit amet, adipiscing elit computer. UT id orci at 195kgs porttitor ipsum. Donec pulvinar purus eget laoreet placerat, sem, dignissim ut auctor libero nisl is justo ac dui. Proin vel libero lectus, lacinia vel massa. Integer eget sapien ac massa lacinia non eros nec mattis. Vivamus ac lacus had convallis malesuada arcu. Amongst leo tincidunt id, posuere vel, bibendum metus malesuada metus. Praesent in sapien, nisi ut sollicitudin odio. Aenean sit amet lorem in eros laoreet congue. Nam tincidunt eros ac faucibus blandit arcu. Morbi pulvinar dui ante no congue in MPCs dapibus neque. Integer tellus and adipiscing placerat ligula eleifend. Nullam nibh nulla, sold had congue sed, pharetra magna EU. Nunc purus, dictum vitae, the ultrices blandit volutpat total had turpis. In euismod faucibus tristique. Amongst eget diam urna. DUIs sem and tincidunt facilisis quis, blandit tempus nunc ligula. Suspendisse sed lectus sit amet quam, eleifend commodo. « ;
    private var _infoArray:Array = _infoText.split("");

    public void InfoPage() {}

    createText();

    for (var i = 0; i < _infoArray.length; i ++) {}
    trace (_infoArray [i]);
    TweenLite.to (_infoArray [i], 1, {alpha: 1, ease:Cubic.easeOut});})
    }

    }

    private function createText (): void {}

    var _font: make = new Font();
    var _tf:TextFormat = new TextFormat();
    _tf.font = _font.fontName;
    _tf. Size = 14;
    _tf. Color = 0 x 333333;
    _tf. Leading = 3;

    _info = new TextField();
    _info. Name = "info";
    _info.defaultTextFormat = _tf;
    _info.antiAliasType = AntiAliasType.ADVANCED;
    _info.embedFonts = true;
    _info.WordWrap = true;
    _info. Multiline = true;
    _info. Selectable = false;
    _info. Text = _infoText;
    _info.x = 10;
    _info.y = 116;
    _info. Width = 800;
    _info. Height = 400;

    addChild (_info);



    }
    }
    }

    1 make sure that your textfield is added to the displaylist.

    2. make sure that your fla is published for actionscript 3.

    3 use:

    private void typeText(e:Event) {}
    index ++;
    If (index<_infoText.length)>
    _info. AppendText (_infoText.charAt (index));
    } else {}
    removeEventListener (Event.ENTER_FRAME, typeText);
    }
    }

Maybe you are looking for