How to extract 3 or n - th element of a string separated by commas

Hello

Let's say I have a string "oracle, java, .net, perl, basic, html.
and I want to extract the 4th item.

Please guide me

Thanks in advance

Try this

http://nimishgarg.blogspot.com/2010/06/Oracle-nth-record-from-comma-seprated.html

for example:
SELECT REGEXP_SUBSTR(MYCOL, '[^,]+', 1, *4*) AS VAL
Of
(
SELECT 'oracle, java, .net, perl, basic, html.
AS DOUBLE MYCOL.
)

Alexander gelin
http://nimishgarg.blogspot.com/

Tags: Database

Similar Questions

  • How to split string separated by commas and pass to the clause of the select statement

    Referring to article How to divide string separated by commas, then pass to clause of a select statement, tquery that there the following plan:

    Query1:

    select * from emp where ename in (
        select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual
        connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null );
    

    Base1:

    Plan hash value: 4242290184
    
    
    --------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |          |     1 |   133 |     7  (29)| 00:00:01 |
    |*  1 |  HASH JOIN                      |          |     1 |   133 |     7  (29)| 00:00:01 |
    |   2 |   VIEW                          | VW_NSO_1 |     1 |    46 |     3  (34)| 00:00:01 |
    |   3 |    HASH UNIQUE                  |          |     1 |       |     3  (34)| 00:00:01 |
    |*  4 |     CONNECT BY WITHOUT FILTERING|          |       |       |            |          |
    |   5 |      FAST DUAL                  |          |     1 |       |     2   (0)| 00:00:01 |
    |   6 |   TABLE ACCESS FULL             | EMP      |    14 |  1218 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - access("ENAME"="$nso_col_1")
       4 - filter( REGEXP_SUBSTR ('SMITH,ALLEN,WARD,JONES','[^,]+',1,LEVEL) IS NOT NULL)
    

    However, the following query generates the plan I want:

    Query2:

    select * from emp where ename in ('SMITH','ALLEN','WARD','JONES');
    

    Plan2:

    Plan hash value: 3956160932
    
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     4 |   348 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     4 |   348 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - filter("ENAME"='ALLEN' OR "ENAME"='JONES' OR "ENAME"='SMITH' OR
                  "ENAME"='WARD')
    

    Can I change the query1 query for plan2?

    As Juliet was mentioned in the first SQL that you generate from the ENAME list that you must pass in the IN clause when executing. But in the second SQL, it passed as a static value. So first SQL must do more work. So you see a different execution plan.

    But this is a work around to get what you are looking for. But I can't say it's a foolproof method. But anyway here you go.

    SQL > var ename_list varchar2 (100)
    SQL > exec: ename_list: = 'SMITH, ALLEN, WARD, JONES ';

    PL/SQL procedure successfully completed.

    SQL > select *.
    2 of PEM
    where the 3 «,» | : ename_list | ',' like '%', | Ename | ',%';

    EMPNO, ENAME, JOB HIREDATE DEPTNO ID COM SAL MGR
    ---------- ------ --------- ---------- --------- ---------- ---------- ---------- ----------
    7369 SMITH COMMITTED 7902 2975 2 APRIL 81 0 20
    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
    7566 JONES MANAGER 7839 2975 2 APRIL 81 0 20

    SQL > select * from table (dbms_xplan.display_cursor);

    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------------------------------
    SQL_ID, 848zhvbvgf7d6, number of children 0
    -------------------------------------
    Select * from emp where «,» | : ename_list | ',' like '%', | Ename
    || ',%'

    Hash value of plan: 2872589290

    --------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      |       |       |     2 (100) |          |
    |*  1 |  TABLE ACCESS FULL | EMP |     1.    38.     2 (0) | 00:00:01 |
    --------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 - filter(','||:ENAME_LIST||',' LIKE '%,'||") ENAME "|", %')

    19 selected lines.

    SQL >

  • How to extract the value of the element as an array in javascript

    Hi all

    I want to do some calculations on the value entered by the user in the textfield of a tabular presentation, how can I retrieve the value of the element as an array in javascript?

    I use as a normal, do not use in the form of apex_item.

    I can pass the current value of the textfield to the function using 'this' as a parameter, but how can I retrieve the value of other lines of the same column?

    Thank you
    Tauceef

    If it is a page element wouldn't be better to make a calculation of point page when onload of the page? Just do a SQL as select sum (col1) of dual nationality or whatever is your table/column?

  • How to extract a number of length fixed to a string

    Hello
    I have a requirement to find all numbers of 9 digits in a string with delimiters.
    I tried
    SELECT REGEXP_SUBSTR (REPLACE ('12345678978979798ZXC3ASD456FGH8TED63456789123',' '),'[[: digit:]] {9}') FROM dual
    WHERE REGEXP_SUBSTR (REPLACE ('12345678978979798ZXC3ASD456FGH8TED63456789123',' '),'[[: digit:]] {9}') IS NOT NULL;

    It gives me 123456789
    But I want to output of

    123456789 634567891
    Help, please.

    Thank you
    G

    Use Back-referencing to extract all the secondary channels of a particular model:

    Ranit>> with xx as(
      2       select '12345678978979798ZXC3ASD456FGH8TED63456789123' x from dual
      3  )
      4  select
      5  replace(regexp_replace(x,'([[:digit:]]{9})|.','.\1'),'.')
      6  from xx;
    
    REPLACE(REGEXP_REP
    ------------------
    123456789634567891   
    

    @NSK - what will happen if a 3 ^ rd ^ substring exists? You have hardcoded for 2 SUBSTRs.

  • Verification of an element in one string from another string

    Hi guru,.

    I have 2 strings separated by commas. Say it like that.

    a VARCHAR2 (100): = '1,2,3,4,5,6,7,8,9,10';
    b VARCHAR2 (100): = '2,6,9';

    My requirement is like I want to check the chain has, if it has all of the b element. I am using the regular expression. But I wasn't able to do.
    Kindly help me.

    Kind regards
    VJ

    Hello

    I'd probably use the Michaels, but if you want to see how you could do this using regular expressions:

    SELECT     *
    FROM     table_x
    WHERE     REGEXP_LIKE ( ',' || a || ','     || '/' ||
                    ',' || b || ','
                  , '(,[^,]+,).*/.*\1'
                  )
    ;
    

    where "/" is known not either a or b.

  • How to extract the signal from the waveform of my power level designated?

    Hi all

    How can I extract the signal of the waveform accroding to the power level? I read the Trigger & Gate .vi, but this vi retrieves the signal duration. I want to extract the signal depending on the power level.

    As shown in the following figures, the signal I want to deal with is between 130000 to 140000, if I Zoom, I can see the useful signal is between 135400 to 138200. The question is how to extract the signal in the area?

    I tried the sub_NoiseEst_And_Chop_Shell.vi in the example of Packet_based_link also, but this Subvi seems to be a bit slow. Can someone give me the best advice? Thanks in advance!

    I'm working on something similar, but have not had time to fully develop.

    My idea was to use an envelope detector (low pass filter) and then use a detection of energy VI on the envelope.

    Here is where I left

  • How to extract 1 ASA and put them in the new table

    Hello

    Can someone tell me how to extract a table and put in the new table. (eg. I have a table with no 1 to 1000, I would extract only 1, 30, 60, 90,...)  ?

    Please advise me.

    Thank you

    concerning


  • Need urgent help! In my Vision Application, how to extract the parameters of the geometric model specified curve was generated by the template editor OR?

    I have an application of machine vision, in which the geometric pattern match technique was used to find the target in the images of type variant.

    as we know, we do a geometric model by model OR editor in the editor we can adjust the parameters of the curve specified settings to get the desired curves and we derive the custom box to ignore during the match. then we save the use of the same model in our application of vision.

    Now my question is coming. When I program my request for the geometric game. I have specified the parameters of the curve for the entrance of the IMAQ Advanced Setup learn ringtone 2, of course, I have to adjust this identical to the model, but I don't know how we extract the geometric model. I tried all the methods, for example, I can read data custom, IMAQ get characteristics of the geometric model(it's just for the basic functionality? so is there even a VI based edge?), even at anasys PNG file formats! But I can't read the info of the geometric model by myself!

    It is also illogical to adjust the CURVE SETTINGS manually again for the " IMAQ Advanced Setup Learn Pattern 2" after that I already have in the template editor OR!

    Hello

    Why do you need to specify the curve settings once again, if you have already built a model using the template editor? You don't need to use "IMAQ Advanced Setup learn geometric model 2 VI" to find games (see the attached example).

    You can wire the 'curve settings' control to 'IMAQ configuration geometrical game model 2 VI', but the values are not used if wire you a Boolean true to the node "use learning curve settings" (it's like that by default). To prove it, I enclose a small program with pre-created model (using the template editor) for a geometrical alignment. The model and the test of three images are also included.

    Try changing the settings of the curve with the 'use know curve settings' enabled, and you will see the corresponding score remains the same. Disable the Boolean control, then try to change the curve settings.

    Also take a look at the detailed help for "IMAQ configuration geometrical game model 2 VI", specifically the "learning curve parameters of use."

    I hope this helps.

    Best regards

    K

  • How to extract photos from my phone to my computer?

    How to extract photos from my phone to my computer?

    Maybe the info will help you get started...

    You have a card reader and an adapter for
    the memory card?

    Or... you have a USB cable that is made to adapt to the
    port on the phone?

    A fair example for info (you'll need a specific
    for your memory card):

    MICRO SD 2 GB MEMORY CARD
    http://sale.images.Woot.com/Kingston_2GB_Micro_SD_Card_with_Adaptera75Detail.jpg

    And... the following article might be worth a visit:

    How to unload your cell phone photos
    http://www.PCMag.com/Article2/0, 2817,2348830,00.asp

    Reach... Start / computer... and the card reader or phone
    Admittedly with a drive letter. If you right-click
    the drive letter, you can display the directory of the memory
    Card and copy the photos.

  • How to extract data using bluetooth other device...

    Hi all

    First, I describe my problem:

    I want an application that extract the xml data in ECG device using bluetooth after accessing this data make some calculation and send it to the server... I am able to serach all the device compatible bluetooth after that, I am also able to connect from the particular device... (Now I use bluetooth Simple device as phone, pc or anything which is Bluetooth)

    Now the problem is... After connection of the device, I want to go get a (for example an image or text document.) file of the device connected using my camera...

    can anyone know how to extract data or file to another device that is currently associated with my camera... using BlackBerry device...

    Please help me to overcome this problem...

    Currently, I am working with Blackberry.6

    As suggested, I would recommend you try the samples provided.

  • How to extract string in JSON data where the value in a table

    Hello

    Structure of JSON string

    {'name': 'John', 'name': 'kumar', 'address': [{'Address1': 'value', 'place': 'value'}, {'address2': 'value', 'place': 'value'}]}

     


    How to extract the value of the address of the list.

    If you have control over the format of data, it is best to rename address1 and address2 to have the same name, for example "address". Then, it can be analyzed that way (I've also simplified other code a bit):

    JsonDataAccess jda;
    QVariant v = jda.loadFromBuffer(jsonString);
    QVariantMap m = v.toMap();
    QString name = m["name"].toString();
    QString surname = m["surname"].toString();
    QVariantList addresses = m["address"].toList();
    foreach (QVariant addr, addresses)
    {  QVariantMap addrMap = addr.toMap();
      QString addressValue = addrMap["address"].toString();
      QString place = addrMap["place"].toString();
    }
    
  • How to extract the music

    Hi when I put the cd in my laptop to play or rip music, that nothing appears on my desk for me to make suggestions would be welcome I use Windows 7 by the way

    Hey JC,.

    Here is a good article How to Microsoft go off on how to extract music from a CD in Windows 7. Here is the link: rip music from a CD in Windows Media Center.

    The feature you're talking about is also CPEI be disabled or enabled. You can change the disable? Here is a link on how to turn off the feature, but of course you can follow to ensure that the feature is enabled as well. How to disable the feature that allows Audio CDs and CD-ROMs to run automatically

    Good luck!

    Sean

  • How to extract files from the Windows 7 installation CD?

    I remember that on Win98, I can use SFC. EXE to extract all those files. CAB files on the installation of Win98 CD and place the files extracted into a folder I want. In addition, I don't need to know where. CAB of the target file should be some.

    The SFC. EXE in Win7 replces only system files. It does not extract and put all the files as the SFC in Win98.

    So, how to extract files from Windows 7 installation CD?

    Hello

    ·         Why you want to extract the file from the Windows 7 DVD?

    ·         What file you want to extract?

    Some of the files will be locked or currently in use by the system so that you will not be able to replace their while that started in Windows 7. Therefore, SFC scan tool is used to repair any file corruption in windows 7.

    Design by default, you can extract the files. You can copy and paste the file into your Windows 7 DVD drive, refer to the article below:

    http://Windows.Microsoft.com/en-us/Windows7/copy-and-paste-a-file

    Hope this helps,

  • How to measure a distance in photoshop elements 14? any tool?

    How to measure a distance in photoshop elements 14? any tool?

    You can use the online tool and watch the L (length) in the box in the document area or in the window > Info Panel.

    The length is displayed in you have units of the rule value, such as inches, pixels or...

  • How to straighten a photo in Photshop Elements 9?

    How to straighten a photo in Photshop Elements 9?

    Dayhiker4k wrote:

    How to straighten a photo in Photshop Elements 9?

    Go to the menu Filter > Correct camera distortion.

Maybe you are looking for