Split the cell enclosed in several lines using REGEXP_SUBSTR - Performance?

Hello

I have a table that has about 20,000 lines. There is a column called key word which has values like below:

File_id Keyword
1SMITH; ALLEN; WARD; JONES; BRADY
2S & P500; TOPIX
3SMALL; LARGE; MEDIUM

I want to display the data like this:

File_id KEYWORD
1SMITH
1ALLEN
1WARD
1BRADY
2S & P500
2TOPIX
etc.

I use this application and it works:

SELECT STG. FILE_ID, REGEXP_SUBSTR (STG. KEYWORD ' [^;] +', 1, LEVEL) AS A KEYWORD OF STG STG_TABLE

CONNECT REGEXP_SUBSTR (STG. KEYWORD ' [^;] +', 1, LEVEL) IS NOT NULL

But its so slow its unusable.

Is there a faster way to return this output?

Other info:

KEY Word is varchar2 (4000), but rarely more than 100 bytes are used

Oracle 11g 2

Thank you!

Wrong approach, there are too many lines that are generated

Apart from replacing regexp with substr/instr, try the first slot

SELECT

STG. FILE_ID

REGEXP_SUBSTR (STG. KEYWORD ' [^;] +', 1, LEVEL) AS KEYWORD

OF STG STG_TABLE

CONNECT

level<= regexp_count(stg.keyword,';')="" +="">

and prior STG. FILE_ID = STG. FILE_ID

and prior sys_guid() is not null

Tags: Database

Similar Questions

  • How to use the checkbox to select several lines of af: table

    Hi all
    I want to use the checkbox to select several lines of af: table

    Kind regards
    Tom

    Hello

    look at this link
    http://Sameh-Nassar.blogspot.com/2009/12/use-checkbox-for-selecting-multiple.html

    Kind regards
    Felix

  • How do you install the creative cloud on several computers using the same license?

    How do you install the creative cloud on several computers using the same license?

    Installation on multiple computers can be done independently of the subscription.  You only need the lic3ense when it comes to activation, you have two active facilities (signed in).  Just install the desktop application and use it to install the applications, and then connect to activate.

    https://helpx.Adobe.com/creative-cloud/help/download-install-app.html

    Creative cloud to desktop
    https://helpx.Adobe.com/creative-cloud/help/creative-cloud-desktop.html

    Sign out, sign in | Creative office cloud app
    http://helpx.Adobe.com/creative-cloud/KB/sign-in-out-creative-cloud-desktop-app.html

    Help of activation & deactivation
    https://helpx.Adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html#a ctivate-how-to's

    Install, update, or uninstall applications
    http://helpx.Adobe.com/creative-cloud/help/install-apps.html

  • Update of several lines using the join condition

    Hi all

    CREATE OR REPLACE
    PROCEDURE update_t
    IS

    BEGIN
    SheikYerbouti IN (SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME FROM hr.employees)
    LOOP
    UPDATE
    HR.employees1
    SET
    FOCA =)
    Select concat (FIRST_NAME, LAST_NAME) in the hr.employees where SheikYerbouti. EMPLOYEE_ID = 197);
    END LOOP;
    END update_t;
    /

    I'm trying to update column Foca Employees1 table. When I run this procedure, I get the error

    Error report:
    ORA-01427: einreihig subquery returns multiple rows
    ORA-06512: at "SYSTEM. UPDATE_T", line 13
    ORA-06512: at line 1
    01427 00000 - "einreihig subquery returns several lines.

    Please let me know a solution for this.

    Thank you
    Mathon

    Hello Mathieu,
    in your internal SQL result set is not limited to just one line.
    Try this

    UPDATE hr.employees1 SET
    FIRST_LAST= (select concat(FIRST_NAME,LAST_NAME) from hr.employees where emp_rec.EMPLOYEE_ID=hr.employees.employee_id);
    

    Your version had no restrictions on selected lines of hr.employees. You gave a where condition clause that is not related to the query.

    The best solution for your problem is to avoid completely any PL/SQL loop. You can try something like this:

    update
       (select
           e1.first_last,
           e.first_name,
           e.last_name
        from
           hr.employees1 e1,
           hr.employees e
        where
           e1.employee_id=e.employee_id) set
       first_last=first_name||last_name;
    

    But beware, the updates on the joints work only under certain restrictions. The key of the table to be updated must be the join key. (key preserved is the word to look for).

    Hope that helps,
    dhalek

  • Separate the phone numbers on several lines

    Hello

    I have a list of phone numbers in a single column. Some cells have 1 phone number, some have 2, and some have 0. Cells with 2 phone numbers are separated by semicolons.

    I need all the phone numbers in a single column with 1 phone number in each row. The order does not matter, so I'll "Sort Ascending" once completed to get rid of the empty cells with no phone number.

    I need a function that takes the numbers after the comma and puts them on their own line in the same column.

    Note that the numbers are in the format: + 1-xxx-xxx-xxxx so if please be aware formatting as text and not as a mathematical equation.

    Thank you in advance.

    Hi B,

    Easy enough, as long as all entries are accurate according to the format you described. Here are two examples, all tous deux two on the same table. The selected cells are part of the first example and are not used in the second.

    End of flag: The two examples use the flag to end on the A11 to indicate when the formulas have reached the end of the list. As entered flag consists of eight occurrences of the text "end" (including the trailing space), with the final space deleted. This will be assimilated by the formula two phone numbers, provide an indicator of the end of each list.


    Example 1:

    Separates the first phone number in column B using this formula in B2, filled up to the last line containing a phone number in column A (or the line beyond if you want that the flag of the 'end').

    B2: = IF (LEN (A) < 1", LEFT(A,15))

    Len (A) checks no entry in its ranks. If that is found, IF put a string NULL. If there is an entry, LEFT out the first 15 characters.

    The second n phone number each line is copied into column C with this similar formula in C2 and filled up to the last line containing an entry in column A.

    C2: is equal to IF (LEN (A) < 16", RIGHT(A,15))

    If there are two numbers in this line from A cell, the semi colon will be the 16th character.

    After having extracted the numbers in two columns:

    Select all the cells in column B of B2 on the last containing a B10 number in this example). Copy.

    Go menu Edition > paste formula results

    Select all the cells in column C of C2 on the last containing a number C10). Copy.

    Click once on the empty cell in column B, following the list of the "first numbers" (B11 in this example).

    Go to edit > paste the results of the formulas.

    You can now sort the table according to the values (telephone numbers) in column B.

    Example 2:

    Separates the first phone number in column B using this formula in B2, filled up to the last line containing a phone number in column A (or the line beyond if you want that the flag of the 'end').

    B2: = IF (LEN (A) < 1", LEFT(A,15))

    Len (A) checks no entry in its ranks. If that is found, IF put a string NULL. If there is an entry, LEFT out the first 15 characters.

    The second phone number n that each line is copied into column B, starting after the cell containing the flag of the 'end '.

    Enter the following formula in the marketing of cells (B12 in the example) and fill down until the formula produces another flag to end.

    B12: = IF (LEN (A2) < 16", RIGHT(A2,15))

    Note that because this version of the formula is not on the same line as the EMF of the cell that is copied the phone number, it must the line included in the references.

    When the terminator is reached:

    Click on each of the cells that contain the end flags, and then press DELETE to remove the flags from the list.

    Select all THE cells B2 at the end of the list of telephone numbers. Copy.

    Go menu Edition > paste formula results

    With replaced by their latest results calculated formulas, you can now sort the table on column B.

    Kind regards

    Barry

  • Updated several lines using BOX WHEN

    I have the table ACCOUNT of structure as follows:

    Account_id ACCOUNT_STATUS
    0044607212
    0420562915
    6012720653

    I need to update the three rows at a time using a SELECT statement such that the second column will be respectively 5, 3, 2.
    I used the following query but it seems something is missing

    UPDATE ACCOUNT
    SET ACCOUNT_STATUS = CASE  
    WHEN ACCOUNT_STATUS = '004460721' THEN 5 
    WHEN ACCOUNT_STATUS = '042056291' THEN 3 
    WHEN ACCOUNT_STATUS = '601272065' THEN 2 
    WHERE ACCOUNT_ID IN ('004460721','042056291','601272065') 

     

    My question is this correct way? If not, I can use CASE WHEN statement and how or I only have the choice of use of SUB-SELECT to achieve this objective in a single statement?

    Don't know what SQLFiddle is and the DB, it uses, but it worked at Oracle 10.2.0.5:

    create table account (key primary number account_id,)
    account_status varchar2 (30));

    insert into a values (1, '5') account;
    insert into a values (2, '3') account;
    insert into a values (3, '2') account;

    update account

    Set the account_status CASE account_id =

    WHEN 1 then "2"

    WHEN THEN 2 '5'

    WHEN 3 THEN "3"

    END

    WHERE account_id IN (1,2,3);

    Select *.

    account;

    ACCOUNT_ID ACCOUNT_STATUS

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

    1                      2

    2                      5

    3                      3

  • How to use the checkbox to update several lines

    Hi all

    I'm new to apex and I have a problem now. I find this code somewhere:

    BEGIN

    FOR I IN 1... APEX_APPLICATION. G_F01. COUNTING LOOP

    REMOVE FROM THE ASER

    WHERE ID = TO_NUMBER (APEX_APPLICATION. G_F01 (I));

    END LOOP;

    END;

    It can remove selected items, now I want to make some modifications to it.

    I want to update some columns when I ticked the box. How to make this change? I mean, like this:

    UPDATE ASER SET STATUS = '1' when I selected items

    Can you help me? Thank you!

    Hello

    I don't know exactly what you want to do, but if I am guessing right then of course you want updated also based on the elements of the selected check box.

    
    BEGIN
     FOR I IN 1 .. APEX_APPLICATION.G_F01.COUNT LOOP
    
       DELETE FROM ASER
      WHERE ID=TO_NUMBER(APEX_APPLICATION.G_F01(I)) ;
    UPDATE APSER
    SET STATUS = 1
    WHERE ID=TO_NUMBER(APEX_APPLICATION.G_F01(I)) ;
       END LOOP;
    
      END;
    

    But if not and you try rather to use these values to update another table after Session State is the way to go.

    Kind regards

    Benjamin.

  • Is it possible to split the Windows 7 on several hard drives?

    Hi all!

    I have a question I asked on for a while and have never found an answer to.

    I use Linux and Windows together and I like the two operating systems, and one thing I LIKE about Linux, it is how it is easy to split on several partitions/hard disks.  If I want to put my/home folder on a different partition of the root folder that is located on a different drive of my Swap and / boot partitions, no problem! In fact, in some ways, it is almost encouraged/forced to make a system like this.

    Now, my question is can I do the same thing during the installation of Windows? (I mean Windows 7, but a response for all versions would be nice, too.) Specifically, can I have my 'Program Files' and the contents of the "Program Files (x 86)" folder exists on another drive and the rest of Windows partitions and have these partitions mounted these subfolders under C:\? The reason why I ask is that I received a Solid State Drive, and I don't want to fill it with all my programs/games that exist in those folders.

    Thanks a lot for the answers you can provide.

    Sincerely,

    Austin

    There are some things you can do with Windows, but not to the same extent as Linux. Read the article below.

    How to pass Windows 7 to a larger hard drive to a smaller SSD drive using Acronis True Image:
    http://www.PAGESTART.com/win7sddatihim05011201.html

    J W Stuart: http://www.pagestart.com

  • ETL - split manually entered data on several lines

    Hi people. The question of an experienced Oracle semi programmer...

    I'm looking for some advice on an elegant solution and/or good performance for a lot of food data our database Oracle (10 g R2).

    The source data are entered manually and contains invalid entries. More important, a good percentage of the data contains several purchase order numbers into one field in the source, for example ("123456789, 987654000, 987654003, 987654006, 4008-4010').

    In the destination table, I want each of these purchase orders to be its own record.

    Any thoughts on a good approach to this? I read a few articles on Asktom.com on the 'pipeline functions', but since it is done on the back-end (client only comes into play until after I confirmed the results), I didn't know if I could derive all the benefits of lines own 'pipes' to a single DML vs coating DML statement in my PL/SQL.

    The database "at a distance" from the source is also Oracle 10 g 2, if that matters.

    I recently discovered how elegantly I could go the other way - compilation of the string fields to multiple records in a single string concatenated to the destination folder using analytical functions. Could take a PL/SQL process that ran for almost half an hour up to seconds in a single SQL statement. = D

    Hoping maybe one of the experts can point me in the right direction here. Thanks in advance for any advice you can offer.
    with t1 as (
                select '100000,100,103,105-109' str from dual union all
                select '200000,200,203,205-209' str from dual
               ),
         t2 as (
                select  str,
                        regexp_substr(str,'[^,]+') first_element,
                        column_value element_number,
                        regexp_substr(str,'[^,]+',1,column_value) element
                  from  t1,
                        table(cast(multiset(select level from dual connect by level <= length(regexp_replace(str || ',','[^,]'))) as sys.odciNumberList))
               ),
         t3 as (
                select  str,
                        first_element,
                        element_number,
                        element,
                        regexp_substr(element || '-' || element,'[^-]+') start_sub_element,
                        regexp_substr(element || '-' || element,'[^-]+',1,2) end_sub_element
                  from  t2
               )
    select  str,
            case element_number
              when 1 then to_number(first_element)
              else to_number(first_element) + to_number(start_sub_element) + column_value - 1
            end val
      from  t3,
            table(cast(multiset(select level from dual connect by level <= end_sub_element - start_sub_element + 1) as sys.odciNumberList))
    /
    
    STR                           VAL
    ---------------------- ----------
    100000,100,103,105-109     100000
    100000,100,103,105-109     100100
    100000,100,103,105-109     100103
    100000,100,103,105-109     100105
    100000,100,103,105-109     100106
    100000,100,103,105-109     100107
    100000,100,103,105-109     100108
    100000,100,103,105-109     100109
    200000,200,203,205-209     200000
    200000,200,203,205-209     200200
    200000,200,203,205-209     200203
    
    STR                           VAL
    ---------------------- ----------
    200000,200,203,205-209     200205
    200000,200,203,205-209     200206
    200000,200,203,205-209     200207
    200000,200,203,205-209     200208
    200000,200,203,205-209     200209
    
    16 rows selected.
    
    SQL> 
    

    SY.

  • Calculation of the time differences between several lines

    Hello

    I have a table as below:

    EVENT ID DATE
    1. start 05/03/2012-13:00
    1. stop the 15:00 05/04/2012
    1. start 09:00 05/07/2012
    1 stop on 05/09/2012 10:00
    Start 2 08/06/2012-08:00
    2 stop on 08/07/2012 10:00

    I would like to calculate the duration (in hours ideally) between 'Start' and 'Stop' for each ID, so having a set of lines:

    ID TimeSpan
    ---------------------
    1 75
    26 2

    I would appreciate any idea how to solve this, ideally as a SQL solution or maybe a function.

    Thank you very much!
    Tom

    The difference between two dates is a number, where 1 = 1 day. Multiply by 24 to get hours.

    Use the LAG, as stated above, to compare the date prior to the current date.

    create table T(TID, EVENT, TDATE) as select
    1, 'start', TO_DATE('03/05/2012 13:00:00', 'dd/mm/yyyy hh24:mi:ss') from DUAL union all select
    1, 'Stop',  TO_DATE('04/05/2012 15:00:00', 'dd/mm/yyyy hh24:mi:ss') from DUAL union all select
    1, 'start', TO_DATE('07/05/2012 09:00:00', 'dd/mm/yyyy hh24:mi:ss') from DUAL union all select
    1, 'Stop',  TO_DATE('09/05/2012 10:00:00', 'dd/mm/yyyy hh24:mi:ss') from DUAL union all select
    2, 'start', TO_DATE('06/08/2012 08:00:00', 'dd/mm/yyyy hh24:mi:ss') from DUAL union all select
    2, 'Stop',  TO_DATE('07/08/2012 10:00:00', 'dd/mm/yyyy hh24:mi:ss') from DUAL;
    
    select tid, round(sum(hours)) hours from (
      select case
        when EVENT = 'Stop' then 24*(TDATE - LAG(TDATE) over(partition by TID order by TDATE))
        else 0 end hours,
      TID from T
    )
    group by tid;
    
    TID HOURS
    --- -----
      1    75
      2    26
    
  • Need help to insert several lines using PL/SQL

    Hi gurus,

    I wrote a simple PL/SQL to insert the recrods in a table. It works fine if the sql script that is stored in the column to the table TEST_VALIDATION SCRIPT returns a single line. Can you get it someone please let me know a better way to insert multiple results returned by the script? Rest columns can be duplicated.

    DECLARE

    p_rows default NUMBER of 0;

    CURSOR C1_TV
    IS
    SELECT ID, DESCRIPTION, TEST_VALIDATION SCRIPT;

    BEGIN

    FOR C1_TV_REC in C1_TV
    LOOP

    Run immediate C1_TV_REC. SCRIPT in p_rows;

    INSERT INTO THE VALIDATION
    (END_DATE,
    VALIDATION_ID,
    VALIDATION_DESCN,
    VALIDATION_COUNT
    )
    VALUES
    (
    (select sysdate to DOUBLE),
    C1_TV_REC.ID,
    C1_TV_REC. DESCRIPTION,
    p_rows
    );

    COMMIT;

    END LOOP;

    END;
    /

    Please let me know if this isn't clear.

    Thank you
    Shash

    You need something like that

    declare
      p_rows dbms_sql.number_table;
      i pls_integer;
    begin
      execute immediate SCRIPT bulk collect into p_rows;
      i:=1;
      loop
        exit when i>p_rows.count;
        insert... p_rows(i)....
        i:=i+1;
      end loop;
    end;  
    

    or the much faster method (if it works in your case)

    declare
      p_rows dbms_sql.number_table;
      i pls_integer;
    begin
      execute immediate SCRIPT bulk collect into p_rows;
      forall i in p_rows.first..p_rows.last
         insert into table (field) values (p_rows(i));
    end;  
    

    And why you use

    (select sysdate from DUAL)
    

    Just use

    sysdate
    

    Published by: Oleg Gorskin the 12.01.2010 06:51
    Add method with forall

  • calculate the time difference between several lines

    Hello

    I have a table as below:

    create table select TEST_CASETBL (ID, CASE_NUM, CASE_STATUS, CASE_SUB_STATUS, LAST_UPD_DTTM)

    112, 123-456', 'open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' hh24:mi:ss' of dd/mm/yyyy) of the DUAL union all select them

    315, 123-456', 'open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    651, 123-456', 'open', 'Work', TO_DATE (August 20, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') from DUAL;

    I would like to calculate the duration total (days ideally) to CASE_SUB_STATUS, so have a set of lines:

    CASE_NUM of work waiting on admin waiting on customer

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

    123-456 70days 6 hours

    Here is the explanation of the pattern:

    ex: for everyday business computing (timestamp timestamp of ID:651 - ID:219) +(timestamp of ID:315-timestamp of ID:114) + (ID:112 stamp - current_time) = 11 days + 21 days 22hrs 23hrs 36 days 9 hours

    still waiting on admin

    (ID:219 timestamp - timestamp of ID:315) + (ID:113 timestamp - timestamp of ID:112)

    still waiting on the client

    (ID:114 timestamp - timestamp of ID:113)

    I would appreciate any idea how to solve this, ideally as an SQL

    Thank you

    Should he not?...

    with test_casetbl (id, case_num, case_status, case_sub_status, last_upd_dttm) as)

    Select 112, 123-456', 'Open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 315, 123-456', 'Open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 651, 123-456', 'Open', 'Work', TO_DATE (August 20, 2015 10:00 ',' the hh24: mi: ss' dd/mm/yyyy) double

    ),

    t like)

    Select case_num,

    case_sub_status,

    (last_upd_dttm, 1, sysdate) ahead of diff last_upd_dttm (partition by order of last_upd_dttm case_num).

    of test_casetbl

    )

    Select case_num,

    trunc (a) | "day (s). TO_CHAR (date ' 1-1-1' + a, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "work."

    trunc (b) | "day (s). TO_CHAR (day 1-1-1' + b, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") 'Waiting on admin',

    trunc (c) | "day (s). TO_CHAR (day 1-1-1' + c, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "waiting on customer."

    t

    pivot)

    Sum (diff)

    for case_sub_status in)

    'Work' is.

    B "waiting on admin',

    C "customer expectation."

    )

    )

    CASE_NUM Working Waiting on admin Waiting on customer
    123-456 63 day (s) 22 hour (s) (s) 50 minute 49 second (s) 19 day (s) on 20 (s) hour 0 minute 0 second (s) 27 day (s) on 4 hour (s) 0 minute 0 second (s)
  • Extraction of several lines using CONNECT BY

    Hello

    It's the structure of the table:

    CREATE TABLE XX_SHIFT_EXCEPTIONS
    (
    PLANT_SHIFT_EXC_ID     NUMBER(18) NOT NULL,
    START_DATE  DATE NOT NULL ,
    END_DATE              DATE NOT NULL ,
    EXC_START_TIME        NUMBER(18) NOT NULL ,
    EXC_DURATION                   NUMBER(18),      
    EXC_END_TIME           NUMBER(18) NOT NULL);
    
    INSERT INTO XX_SHIFT_EXCEPTIONS
    VALUES
    (1,'27-NOV-2015','30-NOV-2015',1200,480,2000);
    
    INSERT INTO XX_SHIFT_EXCEPTIONS
    VALUES
    (2,'28-NOV-2015','28-NOV-2015',1200,480,2000);
    
    INSERT INTO XX_SHIFT_EXCEPTIONS
    VALUES
    (3,'27-NOV-2015','28-NOV-2015',1200,480,2000);
    

    I want my result to look like this:

    START_DATE END_DATE EXC_START_TIME EXC_END_TIME PLANT_SHIFT_EXC_ID

    1 27 NOVEMBER 2015 27 NOVEMBER 2015 1200 2000

    1 NOVEMBER 28 NOVEMBER 28, 2015 2015 1200 2000

    1 NOVEMBER 29 NOVEMBER 29, 2015 2015 1200 2000

    1 NOVEMBER 30 NOVEMBER 30, 2015 2015 1200 2000

    2 NOVEMBER 28 NOVEMBER 28, 2015 2015 1200 2000

    3 27 NOVEMBER 2015 27 NOVEMBER 2015 1200 2000

    3 NOVEMBER 28, 2015 28 NOVEMBER 2015 1200 2000

    I tried the below:

    SELECT  PLANT_SHIFT_EXC_ID,START_DATE+LEVEL-1 START_DATE,START_DATE+LEVEL-1 END_DATE,EXC_START_TIME,EXC_END_TIME
    from
    (SELECT * FROM XX_SHIFT_EXCEPTIONS
    WHERE TRUNC(END_DATE)!=TRUNC(START_DATE)) SHIFT1
    CONNECT BY LEVEL<=(END_DATE-START_DATE+1)
    UNION ALL
    SELECT PLANT_SHIFT_EXC_ID,START_DATE,END_DATE,EXC_START_TIME,EXC_END_TIME
    FROM XX_SHIFT_EXCEPTIONS WHERE END_DATE=START_DATE
    order by 1,2;
    

    But the result set is not wait for him as for factory shift 1, I get 11 lines instead of 4 rows

    Help, please. Thank you.

    so, something like this:

    WITH XX_SHIFT_EXCEPTIONS (plant_shift_exc_id, start_date, end_date, exc_start_time, exc_duration, exc_end_time)

    AS (SELECT 1, to_date (27 November 2015 "," MON-DD-YYYY ""), to_date (November 30, 2015 "," MON-DD-YYYY'"), 1 200 480, 2000 FROM dual UNION ALL)

    SELECT To_date 2 (November 28, 2015 "," MON-DD-YYYY ""), to_date (November 28, 2015 "," DD-MON-YYYY ' "), 1 200 480, 2000 FROM dual UNION ALL

    SELECT 3, to_date (27 November 2015 "," MON-DD-YYYY ""), to_date (November 28, 2015 "," MON-DD-YYYY'"), 1 200 480, 2000 DOUBLE)

    SELECT PLANT_SHIFT_EXC_ID, START_DATE + LEVEL 1 START_DATE, END_DATE START_DATE + LEVEL 1, EXC_START_TIME, EXC_END_TIME

    OF XX_SHIFT_EXCEPTIONS

    CONNECT BY LEVEL<= (end_date="" -="">

    AND PRIOR plant_shift_exc_id = plant_shift_exc_id

    and prior sys_guid() is not null

    /

    HTH

  • Update with the Lead feature and several lines

    I have a table such as:

    Table1:

    OrderNumber EFFECTIVE_DATE EFFECTIVE_END_DATE FileName

    123 11/5/2015-12/31/2099 File5.txt

    123, 7/11/2015-12/31/2099 File7.txt

    or it can look like:

    Table2

    OrderNumber EFFECTIVE_DATE EFFECTIVE_END_DATE FileName

    123 11/5/2015-11/7/2015 File5.txt

    123, 7/11/2015-11/9/2015 File7.txt

    123 11/9/2015-12/31/2099 File9.txt

    123 11/15/2015-12/31/2099 File15.txt

    I want to take the 2nd to the last EndDate and update with the previous value.

    So in fact, it would look like this.

    Table1:

    OrderNumber EFFECTIVE_DATE EFFECTIVE_END_DATE FileName

    123 11/5/2015-11/7/2015 File5.txt

    123, 7/11/2015-12/31/2099 File7.txt

    or

    Table2

    OrderNumber EFFECTIVE_DATE EndDate FileName

    123 11/5/2015-11/7/2015 File5.txt

    123, 7/11/2015-11/9/2015 File7.txt

    123-11/9/11/15 to 2015/2015 File9.txt

    123 11/15/2015-12/31/2099 File15.txt

    I got it work in a select statement to a single value. now I just need help it enter an UPDATE statement and update all records.

    SELECT W.EFFECTIVE_DATE, W.EFFECTIVE_END_DATE,

    NVL (LEAD (W.EFFECTIVE_DATE, 1) (ORDER implementation W.EFFECTIVE_DATE), December 31, 99 ') AS 'EFFECTIVE_DATE_NEW '.

    OF WH_ORDERS_REPORT W

    WHERE ORDERNUMBER = '10460992';

    It did not work:

    UPDATE WH_ORDERS_REPORT WH

    SET EFFECTIVE_END_DATE = (SELECT NVL (LEAD (WH2. EFFECTIVE_DATE, 1) (ORDER of WH2. (EFFECTIVE_DATE), DECEMBER 31, 99 ')

    OF WH_ORDERS_REPORT WH2

    WHERE WH. ORDERNUMBER = WH2. ORDERNUMBER)

    I appreciate your help in the creation of an update statement to do this.

    Rap, but it's working now.  I'll confirm with a few other records before I mark as correct, but what I see so far, it is beautiful, thank you!

    merge into WH_LIFELINE_ORDERS_REPORT D

    a_l'_aide_de)

    Select

    DISTINCT ORDERNUMBER,

    CURRENTSTATUSDATETIME,

    NVL (LEAD(EFFECTIVE_DATE, 1) ON (ORDERNUMBER partition

    (EFFECTIVE_DATE order), December 31, 99 ') as EFFECTIVE_END_DATE

    of WH_LIFELINE_ORDERS_REPORT

    ) S

    WE (D.ORDERNUMBER = S.ORDERNUMBER

    AND D.CURRENTSTATUSDATETIME = S.CURRENTSTATUSDATETIME

    )

    When matched then

    setting a day of set D.EFFECTIVE_END_DATE = S.EFFECTIVE_END_DATE;

  • Insert the statement with the subquery to insert several lines

    Hi friends,

    Please find below mentioned query and error. Also suggest me to go forward.

    SQL > INSERT INTO FM_TRAN_DOC_NO (TDOC_COMP_CODE,

    2 TDOC_TRAN_CODE,

    TDOC_ACNT_YEAR 3,.

    TDOC_CUR_NO 4,.

    TDOC_MAX_NO 5,.

    TDOC_CAL_YEAR 6,.

    TDOC_PERIOD 7,.

    TDOC_DIVN_CODE 8,.

    TDOC_DEPT_CODE 9,.

    TDOC_CR_UID 10,

    TDOC_CR_DT 11,

    TDOC_UPD_UID 12,

    13 TDOC_UPD_DT)

    14 SELECT '001',

    15 (SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE

    16               '6',

    17               '0',

    18 '9999',

    19 NULL,

    20 NULL,

    21 NULL,

    22 NULL,

    23 "AGT,"

    24 TO_DATE (SYSDATE),

    25 NULL,

    26 TO_DATE (SYSDATE) FROM DUAL;

    (SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE),

    *

    ERROR on line 15:

    ORA-01427: einreihig subquery returns multiple rows

    +Untested.

    When values except 'TDOC_TRAN_CODE' are hardcoded, there is no need to select double.

    Something like that?

    INSERT INTO FM_TRAN_DOC_NO)

    TDOC_COMP_CODE,

    TDOC_TRAN_CODE,

    TDOC_ACNT_YEAR,

    TDOC_CUR_NO,

    TDOC_MAX_NO,

    TDOC_CAL_YEAR,

    TDOC_PERIOD,

    TDOC_DIVN_CODE,

    TDOC_DEPT_CODE,

    TDOC_CR_UID,

    TDOC_CR_DT,

    TDOC_UPD_UID,

    TDOC_UPD_DT

    )

    SELECT DISTINCT

    '001',

    TDOC_TRAN_CODE,

    « 6 »,

    '0',

    "9999",

    NULL,

    NULL,

    NULL,

    NULL,

    "AGT,"

    TO_DATE (SYSDATE),

    NULL,

    TO_DATE (SYSDATE)

    OF FM_TRAN_DOC_NO;

Maybe you are looking for

  • iCal 'Get Info' is grey for the blue calendar; Other calendars are very good. Model name: iMac model identifier: iMac9, 1

    iCal 'Get Info' is grey for the blue calendar; The other color calendars are very good. I deleted the file 'com.apple.iCal.plist '... No luck. Please notify. Thank you, Roger Presentation of the material: Model name: iMac Model ID: iMac9, 1 Processor

  • iTunes download clerical error in the C:\config.msi\11f36a.rbf file

    I am trying to load itunes and get the following error: Error writing to file: C:\Config.msi\11f36a. FBR Check access. QuickTime loads well but not itunes.  I tried the download fix-use only suggested"tools, but it did not work.

  • My CD-ROM can't play any CD

    Hi everyone, I can't play any CD with my DVD RW drive. On right click, there is no option to 'Play', only ejection or copy I was wondering if there is a problem with the driver, or the lens is just dirty. Please help me with this. I tried to check fo

  • VPN Client 3.6.3 question

    We use the PIX 515E (ver 6.2 (2)) like a VPN for remote users solution. The PIX uses OF and does not have the license for 3DES. Remote users have no problems to access the PIX using Cisco VPN Client 3.5.2 but cannot access using Cisco VPN Client 3.6.

  • Import stopped working

    Import stopped working, seemingly at all times and for all devices and locations.  I can't import my iPhones, memory cards or even folders on my computer.  I have re-installed Lightroom 5.7.1 and even improved to 6 to see if it would solve the proble