Problem with REGEXP_SUBSTR

Hello

I'm trying to use the regexp_substr function in Oracle 10 to split a string into several lines (semicolon is the delimiter).

So I use:

Select Site_List, trim(regexp_substr(Site_List, '[^;]+, 1, level)) FROM (Select Site_List FROM ALL_SITES) Connect by  trim(regexp_substr(Site_List, '[^;]+, 1, level)) is not null

No, you did nothing wrong.

Tools such as SQL Developer, TOAD etc. tend to just return the first 50 rows (or however many) very quickly.  It is an indication that the query is performed quickly, but the time it takes to process and send you all data is clearly going to take more time, so if you do a count (*) it must process first before she she can count.

Is the number of rows of data in your table?  How many 'elements' is in each string are some gettnig separated?

I suppose that you run it on multiple lines?

I, in which case you may need to add to your connect by clause that you create a sort - to connect a Cartesian product.

for example, with the following data, we expect 5 rows of two strings...

SQL > ed
A written file afiedt.buf

1 with t as (select 'item1, item2, 3' as txt of the union double all the)
2 Select 'item4, element5' double)
3  --
4. Select txt
5, regexp_substr(txt,'[^,]+',1,level) in el
6 t
7 * connect by regexp_substr(txt,'[^,]+',1,level) is not null
SQL > /.

TXT                        EL
-------------------------- --------------------------
Item1, item2, element1 3
Item1, item2, item2 3
Item1, item2, 3 3
Element4 element5 element5
Item1, item2, 3 3
Item4, element4 element5
Item1, item2, item2 3
Item1, item2, 3 3
Element4 element5 element5
Item1, item2, 3 3

10 selected lines.

but we have more than we expected.

If you try to make sure just connect for each line that you treat...

SQL > ed
A written file afiedt.buf

1 with t as (select 'item1, item2, 3' as txt of the union double all the)
2 Select 'item4, element5' double)
3  --
4. Select txt
5, regexp_substr(txt,'[^,]+',1,level) in el
6 t
7. connect by regexp_substr(txt,'[^,]+',1,level) is not null
8 * and txt = txt prior
SQL > /.

ERROR:
ORA-01436: CONNECT loop in the user data

no selected line

... you get a connection in a loop (cycle) in your data.

This can be achieved by making every single cycle...

SQL > ed
A written file afiedt.buf

1 with t as (select 'item1, item2, 3' as txt of the union double all the)
2 Select 'item4, element5' double)
3  --
4. Select txt
5, regexp_substr(txt,'[^,]+',1,level) in el
6 t
7. connect by regexp_substr(txt,'[^,]+',1,level) is not null
8 and txt = txt prior
9 * and prior sys_guid() is not null
SQL > /.

TXT                        EL
-------------------------- --------------------------
Item1, item2, element1 3
Item1, item2, item2 3
Item1, item2, 3 3
Item4, element4 element5
Element4 element5 element5

so now, we get the 5 rows, as we expected.

I suspect that you produce a lot more lines than you expected.

Tags: Database

Similar Questions

  • Problem with REGEXP_SUBSTR related query.

    I'm having a problem with this query:

    SELECT *.

    FROM (SELECT REGEXP_SUBSTR ('{SUMMER} |)) {} POINT OF SALE}',

    '({)([A-Z]+ *[A-Z]*)(})',

    1,

    LEVEL,

    'I,

    2)

    Val

    OF THE DOUBLE

    CONNECT BY LEVEL < =.

    REGEXP_COUNT ('{SUMMER} |) {} POINT OF SALE} ',' |') + 1)

    WHERE val IS NOT NULL

    I need the output in 2 rows in this format:

    VAL

    ====

    SUMMER

    POINT OF SALE

    But I'm not able to get the "POINT OF SALE" in the output due to space, or perhaps another reason. Anyone can correct my query?

    So, you want something like that?

    SQL > ed
    A written file afiedt.buf

    1. SELECT *.
    2 (SELECT REGEXP_SUBSTR ('{SUMMER} |)) {} POS} ',' [^ {|}] + ", LEVEL, 1, 'i') val"
    3 FROM TWO
    4. CONNECT BY LEVEL<>
    5 REGEXP_COUNT ('{SUMMER} |) {} POINT OF SALE} ',' [^ |] +'))
    6 * val WHERE IS NOT NULL
    SQL > /.

    VAL
    ------------------------
    SUMMER
    POINT OF SALE

    SQL >

  • Problem with regexp_substr if the string with null values between commas.

    Hi all

    My version of DB is 10.1.0.5.0
    I want to extract the string values using query below, but I am unable to provide the correct result.
    WITH t  AS ( select '123,1,3,22' col FROM DUAL
            UNION ALL
            SELECT '123,,2,1' FROM DUAL
            UNION ALL
            SELECT '5,1,2,,' FROM DUAL
            ) 
    SELECT regexp_substr(t.col,'[^,]*',1,1)
          ,regexp_substr(t.col,'[^,]*',1,2)
          ,regexp_substr(t.col,'[^,]*',1,3)
          ,regexp_substr(t.col,'[^,]*',1,4) FROM DUAL,t   ;
    My required result as below.
    123     1      3      22
    123            2       1
    5       1      2        
    Please help me to get the required result by using regular expressions.
    Thanks, Ram

    Hello

    In Oracle 10, you can do so by combining REGEXP_SUBSTR with something else like RTRIM:

    SELECT     RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 1), ',')     AS part_1
    ,     RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 2), ',')     AS part_2
    ,     RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 3), ',')     AS part_3
    ,     RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 4), ',')     AS part_4
    FROM     t
    ;
    

    Starting Oracle 11 REGEXP_SUBSTR alone can do.

    But look at the first response; regular expressions will be probably less effective than less powerful features, especially when all channels have the same number of separators.

    Published by: Frank Kulash on 29 December 2012 08:36

  • Problem with subquery

    Dear all,

    Hope that your door

    I'm having a problem with the sub query. I have to pass several ID for my sub query... but with my request, I only get the correct result...

    Here is the my sample data and my table structure...

    Employee table:

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

    EMPLOYEE_IDNOT NULLNUMBER (16)
    EXTERNAL_ID_1VARCHAR2 (200)
    EXTERNAL_ID_2VARCHAR2 (200)
    JOB_PROFILE_TYPEVARCHAR2 (4)
    FIRST NAMENOT NULLVARCHAR2 (200)
    MIDDLE_NAMEVARCHAR2 (200)

    Table alignment:

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

    ALIGNMENT_IDNOT NULLNUMBER (16)
    TEAM_IDNOT NULLNUMBER (16)
    EMPLOYEE_IDNUMBER (16)
    ALIGNMENT_NAMENOT NULLVARCHAR2 (200)
    EXTERNAL_ID_1VARCHAR2 (200)
    STATUSNOT NULLVARCHAR2 (4)
    STATUS_CHANGE_DATENOT NULLDATE
    MANAGER_ALIGNMENT_IDNUMBER (16)


    Event table:

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

    EVENT_IDNOT NULLNUMBER (16)
    EMPLOYEE_IDNOT NULLNUMBER (16)
    AFFILIATION_IDNUMBER (16)
    CUSTOMER_IDNUMBER (16)
    EXTERNAL_ID_1VARCHAR2 (200)

    Sample data:

    ALIGNMENT_IDALIGNMENT_NAMEEMPLOYEE_IDROLEMANAGER_ALIGNMENT_ID
    1006034672SII-KRN-BANG-A0117452000001661REP1006034513
    1006034673SII-KRN-BANG-A0218910000219453REP1006034513
    1006034674SII-KRN-BANG-A0360000001963804REP1006034513
    1006034675SII-KRN-BANG-A0560000001963706REP1006034514
    1006034676SII-KRN-BANG-A0618910000081856REP1006034514
    1006034677SII-KRN-BANG-B0160000001963699REP1006034513

    My query:

    [code]

    SELECT *.

    Ev EVENT

    INNER JOIN employee e ON e.employee_id = ev.employee_id

    INNER JOIN alignment one ON e.employee_id = a.employee_id AND alignment_id in(:alignment_id)

    [/ code]

    Description:

    I have the data stored in the table in the alignment with the child records and parent records... in the table of alignment, I have the id of the alignment_id alignment and data manager.

    Each rep there would be a single Manager. (manager_alignment_id).

    I have to integrate this query at the front end. .

    At the end I drop down values and will select more than one pass to this request...

    If the selection for alignment_id (rep) then no prob... If they select manager_alignemnt_id then how to pass this value to the query of mu...

    Thanks a lot for your help.

    I'm using the version of oracle 11g.

    Sihem...

    Ideally, the front-end server would be best to store the values in a table (global temporary) and then the request would just join this table to limit the records returned.

    If, for some reason, you can do that, and him are spent as a delimited string (not ideal according to the standards of most of the people), then you have to splits the string to provide the individual values for example

    SQL > ed
    A written file afiedt.buf

    1 Select
    2 of PEM
    3 where empno in)
    4 with t as (select '& input_string' as double txt)
    5 Select REGEXP_SUBSTR (txt, ' [^,] +', 1, level)
    6 t
    7. connect by level<=>
    8*   )
    SQL > /.
    Enter the value of input_string: 7369,7844,7788
    4 old: with t as (select '& input_string' as double txt)
    4 new: with t as (select ' 7369,7844,7788' as double txt)

    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
    ---------- ---------- --------- ---------- -------------------- ---------- ---------- ----------
    7369 SMITH CLERK 7902 DECEMBER 17, 1980 00:00:00 800 20
    7844 TURNER SALESMAN 7698 1981 - SEP - 08 00:00:00 1500 0 30
    7788, SCOTT, ANALYST, 7566 19 APRIL 1987 00:00:00 3000 20

  • problems with, phone, 6, Bluetooth kit, Nissan, after update, for, Rios, 1.0.2

    After the update to ios 10.0.2 - trying to use bluetooth to call my vehicle, it says: "this article is not in your phone book." How can I solve this problem?

    Greetings, joybelino1!

    Thank you for joining the communities Support from Apple! I can't wait to see that you are having problems with your Bluetooth in your car! The good news is that Apple has a great article that will help you with measures to try to resolve the problem. Read this article to gethelp to connect your iPhone, iPad, or iPod touch with your car radio. Even though he talks about problems with the connection, it also has the steps for other questions you may have once connected.

    If you use Bluetooth

    1. Consult the user manual of your car stereo to get the procedure to a Bluetooth device.
    2. On your iOS device, drag up to open Control Center, then press ontwice to turn on Bluetooth and turn it back on.
    3. Restart your iOS device.
    4. On your iOS device, Cancel the twinning of your car radio. On the screen of your car désapparier your iOS device and any other device. Restart your car and your iOS device, then pair and connect again.
    5. Update your iOS device.
    6. Install the updates to the firmware of your car radio.
    7. If you still not connect, contact Apple technical support.

    Have a great day!

  • Anyone having problems with WiFi connectivity after upgrade to Sierra?

    I was wondering if anyone else knows issues with WiFi connectivity since the upgrade to Sierra 10.12? I have not had any problems with connectivity WiFi previously on El Capitan. Now I have regular randomly loose connectivity. My internet is cable and when it is connected I have a 100% connection. My details of iMac and I have used only 10% of my storage.

    No problem with my iphone 6.

    Hello AspDesigns,

    I understand that, since the upgrade to Mac OS Sierra, your Mac seems to have trouble staying connected to Wi - Fi. Fortunately the diagnosis built-in wireless can help identify the source of so much trouble.

    Search for Wi - Fi using your Mac problems

    See you soon!

  • Problems with mail after switching to macOS Sierra

    Hey all

    After having recently upgraded to macOS Sierra, I am unable to read my mail.

    I get the following error every time I check on "Get Mail".

    There may be a problem with the mail server or the network. Check the account settings "*" or try again.

    The server returned the error: Mail could not connect to the server 'pop1.tribcsp.com' using SSL on the default ports. Verify that this server supports SSL and that your account settings are correct.

    What does this error message mean and how can I solve this problem.

    Thank you

    Hi Michael,

    I see your message that you get an error in the mail indicating that there is a problem with the mail server or the network.  To help get this problem resolved, I suggest that you follow the steps below:

    If mail refers to a problem with the mail server, or the network

    Mail will say that it is impossible to connect due to a problem with the mail server or the network. For example, the message may refer to a connection that has expired, or too many simultaneous connections:

    If you are connected to the Internet, but the connection has expired, your email provider might be affected by a discontinuance of service. Contact them or see their status Web page to ensure that their e-mail service is online. Examples of status pages:

    If the message indicates the number of simultaneous connections, too many of your devices is check your e-mail account at the same time. Quit Mail on one or more of your other devices.

    If you are still unable to send or receive e-mails

    1. Make sure that you have installed latest version of the Mac software updates, especially if the problem occurred immediately after the installation of a previous update.
    2. In OS X El Capitan or later version, you can see a status icon and the short error message in the upper right of the Mail window, under the search box. The message may indicate 'Network offline' or 'Connection failed', for example. Click the message to see more details on the issue.
    3. Check your connection to the Mail connection doctor. It might be able to say more on the issue.

    If you cannot send or receive e-mail on your Mac.

    Take care.

  • iMac 27 "mid-2011 - Intermittent problem with CPU fan running at full speed and sleep mode.

    Hello!

    My iMac 27 "has an intermittent problem with the CPU fan runs at full speed. Sometimes it happens at the time when I start it, sometimes only in my session, and sometimes only after a certain time. So does seem to be a problem of "heating".

    Second issue is with the mode 'sleep'. It may occur also at any time, at the start of the iMac, session, or after a certain time. But once he starts to go in mode 'sleep', when I wake up, it goes right back in mode after a few seconds and that it will continue indefinitely until I restart the computer.

    What could be?

    Please help me!

    4ntoine

    Here is my model of iMac:

    iMac 27 "mid-2011 model 12.2

    Intel Core i7 3.4 GHz

    AMD Radeon HD 6970M 1024 MB

    OS X El Capitan 10.11.6
    SMC 1.72f2

    Boot ROM IM121.0047.B23

    reset the SMC

    Reset the management system (SCM) controller on your Mac - Apple Support

  • problem with playing the clash of clans

    I'm having some problems while playing the clash of clans on my 2 mini ipad screen does not seem to meet sometimes as if it was some sort of delay so I have to tap several times in order to use a filter or throw the troops on the battlefield.

    Hi Trinitygr,

    Thanks for posting in the Community Support from Apple! I understand that you are having problems with your iPad screen while playing a game. I like to play games on my iPad and I don't see how this could be a nuisance. I'm happy to offer assistance.

    Are you only had this problem when using the app clash of Clans, or does it happen in all applications? I recommend to start by following the steps described in this article:
    If an application you have installed unexpectedly closes, unresponsive, or does not open

    Take care!

  • I'm having problems with an outdated Apple ID

    I have problems with updating Apps etc in my Apple account because he always asked an obsolete in sign.  How can I change this?

    Hello

    Go down to itunes apple ID Delete page homepage all ID and then add it back back.

    See you soon

    Brian

  • Anyone having problems with the new iPhone LTE connection 7 on Verizon?

    I am now on my iPhone second 7 with Verizon. I had four phones for me and my family. I have now had issues where I have no signal in the same areas where my signal allows to be strong. I can't solve the problem with the activation/deactivation of the airplane and then mode again in normal mode. My phone will rest with no signal for 5 minutes, then going to LTE with three bars. I also had the problem where I had only 1 x signal, while my son standing right next to me has LTE. And he had the same questions, where I'm on LTE and it gets no signal. I use to have LTE where I live and work all the time, now it's spotty at best. Apple has replaced me and my sons iPhones but not luck. Still do. Any ideas or an any other suffering?

    (1) go to settings/cell phone/cellular data Options/enable LTE and select ONLY the DATA. This seems to solve the problem (as a temporary solution) for most of the people affected by this problem. The bad part is your request might not be as clear (since they cannot use the highest LTE signals) and you can make calls and data at the same time. But it does not solve the issue.

    (2) there are rumors (but you didn't hear that from me that we only are not supposed to discuss beta software program Apple in this forum) that the new version of Apple Beta for iOS (which also includes an update of the software carrier Verizon to 26.0) seems to solve this problem. So, there's a light at the end of the tunnel.

  • Problem with some fonts of symbols after the installation of the Sierra

    Hello

    I have recently upgraded the OS on my iMac late 2012 for Sierra, since doing so, I noticed a problem with several fonts.

    All symbolic symbols Apple to Wingdings fonts not correctly displayed in the font book. Apple symbols looks like a standard wheelbase of san, and other symbolic fonts just show as question marks '?' where the images should be.

    In text editing, that I can't even see the symbolic fonts like Zapf Dingbats and Wingdings in the selector. However, they all work well in Adobe Illustrator (CS5) and Microsoft Word 2011. Apple symbols still looks like a standard font.

    I already tried the following:

    1. check the fonts in font book

    2 fix the duplicates in the font book

    3. using the "Restore Standard fonts" option in the font book

    4 deleting a file in the folder Preferences plist Fonts

    5 deleted the cache of police and the database

    I'm out of ideas. Has anyone else had the same problem found a fix?

    Kind regards

    Greville

    I'm just to add that I used the recovery partition to do a clean install of Sierra on a hard drive external and then booted into it to see if it had the same problem.

    And he does. Wingdings and other photo fonts appear as '?' in boxes where the letters must be in the font book.

    So this seems like a problem with the way Sierra displays these fonts, not with the font files themselves.

  • ios10 problem with non-users of iphone messaging

    After upgrading my iPhone 6 ios10, I had intermittent problems with the messaging of Android users (basically, the conversations no iMessage). In about 60% of the time it is not just to deliver the message no matter what I do (pressing the 'Try Again' don't work do not). He has no problem with the reception of the texts, but I can't answer to Android users (Interestingly, I can message users of Android if they are in a group with iPhone users text). I tried everything was updated to the last verision until reset of ios everything.

    I can't find anything online about this. I'm the only one who what?

    Group Messaging uses the MMS. Normal text messages using SMS. SMS uses the voice channel to transfer messages and is strictly a basic function. If you are experiencing problems sending SMS, contact your carrier.

  • I have problems with ios 9.3.5

    my ipod says it's still Friday, September 23 when it is Monday 26 and is stuck in the 04:00 time when I change the time, the screen turns off a color at random, then restarts then both will and I have to change but rest later if it changes at all used to date will not change anything and it runs still works when it wants to and it doesn't stay connected to WiFi , I have the ipod 5th generation and am not elligible for ios 10 Please if you can solve this problem with ios 9.3.5 I would be very grateful as I use my ipod for almost everything. Thanks - René

    It is a community based on the user. You do not speak to Apple directly. You can contact the Apple Support here: http://www.apple.com/ca/contact/

  • I have intermittent problems with iphoto importing from iphone since 0sx 10.11.6. Update

    I have intermittent problems with iphoto importing from iphone since 0sx 10.11.6. -Update

    1 iphoto sees not iphone - restart

    2 iphoto sees iphone but says "no pictures" - restart

    3 Iphoto sees phone and photos and I click Import all or import selected - then I have problem of file format and nothing is imported

    NOTE: I have similar problems with image capture - sometimes you can see the phone and photos, and sometimes is not

    I have an imac 2015 - execution of yosemite

    Help my new iphone because 7 is coming today and I am terrified of the transfer.

    Not sure, but in any case iPhoto is a dead - it would be really smart to learn pictures (a totally new and different program with a learning curve and different workflows)

    With the help of pictures with my new iPhone 7 and iCloud photo library all works well without any problem - nothing different photos with my iPhone except the news and the best quality Photos 5

    LN

Maybe you are looking for

  • Duplication of any libraries - any way to merge?

    Hello In my 'Images' folder, I have now two libraries - iPhoto Library and photo library.  Having considered the two libraries there is a lot of overlap and duplication between them, and as they both occupy about 110 GB each I will refine them.  Y at

  • HP Pavilion 15 laptop: want to buy the to my computer HP PAVILION 15 LAPTOP recovery disk

    My laptop has the stoppage of work yesterday after using the recovery disk created from my Hp laptop which gives the reasons below.Failure of the control of BurnBoot of P2PPPossible causes: -.1.Yello - bang was held at the device2. some failed instal

  • Rename the address of windows live mail.

    I mainly use this e-mail address for businesses and would like to keep my emails and contacts. However, I would like to change the name. Is this possible? If so could you please tell me how to do?

  • Linksys WRT54G2 Set up page!

    I have now reached this page after several unsuccessful attempts, I lost my notes on how do to reconfigure the router I can restore a safe running WiFi I can reset my password, what I did, but I don't know what I am supposed to put or select on the i

  • Microsoft Word (not answer)

    Hello I have VISTA 32 bit and recently installed MICROSOFT HOME AND STUDENT 2010. EXCEL, POWERPOINT, and ENDNOTE work very well, but WORD after a minute of work displays the message "microsoft word (not respondig). I tried to reinstall, but it ends u