create_record, duplicate records < n > times.

HII all,.

I have a detail datablock is;
icode     totqty     perbox     boxes_required
prod1     20     6     4
prod2     10     4     3
prod3     15     4     4
- boxes_required column rounded up (totalqty/perbox).
 
I have a button that when pressed... will bring up a block of data
with records based on the values in column "boxes_required"... something like that...
icode     inbox     box no.
prod1     6     1
prod1     6     2
prod1     6     3
prod1     2     4
prod2     4     5
prod2     4     6
prod2     2     7
prod3     4     8
prod3     4     9
prod3     4     10
prod3     3     11
any ideas how it is possible...
Form6i, db 10g

Kind regards...

Put the NEXT_RECORD after the system.last_record

Tags: Oracle Development

Similar Questions

  • "Compression" duplicate records over time

    Hi, I've been fighting with a problem for a while now and don't know how to solve. I have data that looks like this:


    Code1... Code2... Start_Dt... End_Dt
    A.......... A......... 1/1/2000...12/31/2000
    A.......... A......... 1/1/2001...12/31/2001
    A.......... B......... 1/1/2002...12/31/2002
    A.......... B......... 1/1/2003...12/31/2003
    A.......... A......... 1/1/2004...12/31/2004
    A.......... A......... 1/1/2005...12/31/2005
    A.......... A......... 1/1/2006...12/31/2006

    What I would do in the data store is 'compress' duplicate records, so that the final result should look like this:

    Code1... Code2... Start_Dt... End_Dt
    A.......... A......... 1/1/2000...12/31/2001
    A.......... A......... 1/1/2002...12/31/2003
    A.......... B......... 1/1/2004...12/31/2006

    I can't figure a way to do it. I can just say:

    Select code1, code2, min (start_dt), max (end_dt)

    because I get A codes / has, from 01/01/2000 through 12/31/2006 - is not just, they have changed between the two.

    Does anyone know of a way to do this (base mode GAME please... not to write PL/SQL and do a rank at a time).

    Thanks in advance,
    Scott

    Hi Scott,.
    Try this SQL

    select a_code,b_code,group_id,min(start_date,max(end_date) from
    (select q.*,sum(change_flag) over (partition by a_code,b_code) group_id
            from
            (SELECT a_code,
                    b_code,
                    start_date,
                    end_date,
                    CASE
                    WHEN a_code = lag(a_code,1) over (partition by a_code,b_code ORDER BY start_date)
                       AND b_code = lag(b_code,1) over (partition by a_code,b_code ORDER BY start_date)
                    THEN 0 ELSE 1 END change_flag
                    FROM stp_test) q
    ) q2 group a_code,b_code,group_id
    

    Kind regards
    Oleg

    Edited by: oleg2 09/22/2009 06:30 - Add Group by at the end

  • Recover duplicate records.

    CREATE TABLE TEST (TNO NUMBER (2), TNAME VARCHAR2 (10));

    INSERT INTO TEST VALUES (1, 'TIGER');
    INSERT INTO TEST VALUES (2, 'SCOTT');
    INSERT INTO TEST VALUES (2, 'MILLER');
    INSERT INTO TEST VALUES (2, 'JOHN');
    INSERT INTO TEST VALUES (3, 'SMITH');

    SELECT * FROM TEST;

    NWT TNOM
    ----- ----------
    1 TIGER
    SCOTT 2
    2 MILLER
    2 JOHN
    3 SMITH


    power required:


    NWT TNOM
    ----- ----------
    SCOTT 2
    2 MILLER
    2 JOHN
    I want duplicate records.

    Have you tried the forum search?
    How recover duplicate records have been answered several times ;-)

    select tno, tname from (
       select tno, tname, count(*) over (partition by tno) cnt from test
    ) where cnt > 1
    
  • update with the duplicate record

    I'm working on my update page and I came across the problem where it allows to update the duplicate record. My code works for the second time when I tried to update the same name.

    For example, I have the user name A, B and C of the database.

    For the first time: update the username from B to A. This allowed me to do so given the A user name already in the table. (NOT RIGHT)

    Second step: update the C to A user name. He stopped me because of the duplicate record
    NOT QUITE RIGHT, IT SHOULD BE STOPPED ME FIRST?


    Thank you

    You should probably change the first query if a line with the same id is not considered:


    Select user_name
    users
    where trim (user_name) = ' #trim (form.user_name) #
    and user_id! = #user_id #.

    If all the rows are returned from get_dupecheck then you don't want to do the update.

  • How can I get the clips in record full-time instead of the 25seconds (which seems to be set) when using windows DVD maker

    How can I get the clips in record full-time instead of 25 seconds (that they seem to be defined) using windows DVD maker

    Hi LorraineDawson,

    Here's a walkthough troubleshooting on this issue:

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-creating-a-DVD-video-using-Windows-DVD-Maker

    hope this helps

    B Eddie

  • Matching records between 2 tables with duplicate records

    Hi all

    I need help in what follows.

    I have 2 tables Received_bills and Send_bills.

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

    -The DOF for Table SEND_BILLS

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

    CREATE TABLE SEND_BILLS

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE)

    )  ;

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

    -The DOF for Table RECEIVED_BILLS

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

    CREATE TABLE 'RECEIVED_BILLS '.

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE),

    VARCHAR2 (5 BYTE) 'STATUS' )  ;

    INSERTION of REM in RECEIVED_BILLS

    TOGETHER TO DEFINE

    Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    INSERTION of REM in SEND_BILLS

    TOGETHER TO DEFINE

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.

    Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results

    the query I wrote is this:

    SELECT SEND.*

    REC received_bills, send_bills send

    WHERE send.datum = rec.datum

    AND send.payment = rec.payment

    AND send.code = rec.code

    AND 'rec.status =' SUCCESS

    ;

    The query results give me this

    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1525A5
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1525A5

    The result of the correct application would be

    OCTOBER 10, 1519A1
    OCTOBER 10, 1525A5
    OCTOBER 10, 1519A1

    The select statement that I need I want to use a loop to insert records in another table.

    Can someone help me please?

    Thanks in advance.

    Best regards

    Caroline

    Hi, Caroline.

    Caroline wrote:

    Hi all

    I need help in what follows.

    I have 2 tables Received_bills and Send_bills.

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

    -The DOF for Table SEND_BILLS

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

    CREATE TABLE SEND_BILLS

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE)

    )  ;

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

    -The DOF for Table RECEIVED_BILLS

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

    CREATE TABLE 'RECEIVED_BILLS '.

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE),

    VARCHAR2 (5 BYTE) 'STATUS');

    INSERTION of REM in RECEIVED_BILLS

    TOGETHER TO DEFINE

    Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    INSERTION of REM in SEND_BILLS

    TOGETHER TO DEFINE

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.

    Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results

    the query I wrote is this:

    SELECT SEND.*

    REC received_bills, send_bills send

    WHERE send.datum = rec.datum

    AND send.payment = rec.payment

    AND send.code = rec.code

    AND 'rec.status =' SUCCESS

    ;

    The query results give me this

    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 25 A5
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 25 A5

    The result of the correct application would be

    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 25 A5
    OCTOBER 10, 15 19 A1

    The select statement that I need I want to use a loop to insert records in another table.

    Can someone help me please?

    Thanks in advance.

    Best regards

    Caroline

    Want to get answers that work?  Then make sure that the CREATE TABLE and INSERT statements you post too much work.  Test (and, if necessary, correct) your statements before committing.  You have a stray "." in the first INSERT statement for received_bills and receikved_bills.status is defined as VARCHAR2 (5), but all values are 6 characters long.

    There are 5 lines in send_bills that are similar to the

    10 OCTOBER 2015 19 A1

    Why do you want that 2 rows like this in the output, not 1 or 3, or 4 or 5?  Is it because there are 2 matching rows in received_bills?  If so, you can do something like this:

    WITH rec AS

    (

    SELECT the reference, payment, code

    , ROW_NUMBER () OVER (PARTITION BY datum, payment, code)

    ORDER BY NULL

    ) AS r_num

    OF received_bills

    Situation WHERE = 'SUCCESS'

    )

    send AS

    (

    SELECT the reference, payment, code

    , ROW_NUMBER () OVER (PARTITION BY datum, payment, code)

    ORDER BY NULL

    ) AS r_num

    OF send_bills

    )

    SELECT send.datum, send.payment, send.code

    REC, send

    WHERE send.datum = rec.datum

    AND send.payment = rec.payment

    AND send.code = rec.code

    AND send.r_num = rec.r_num

    ;

    Note that the main request is very similar to the query you posted, but the last condition has changed.

    If you need to insert these lines in another table, you can use this query in an INSERT statement. There is no need of a loop, or for any PL/SQL.

  • APEX 5.0 Export to CSV produces duplicate records

    Good day to you all:

    I use APEX 5.0, and I have a classic report that has a total number of lines of 274.  (274 documents also in SQL Developer).  However, when I export the report to CSV, duplicate records are produced and the total number of lines increases to 365.  Has anyone already known this before bug in APEX 5.0?  I tried to reproduce the report to a type of interactive, but I get the same results when you export to CSV.  Advice or guidance would be appreciated.  Thank you.

    Aqua

    Hey Aqua,

    If you are APEX 5.0.0 or 5.0.1? And which version of the database, you are on?

    There was a problem with CLOB (which are used for the download) in 5.0.0 running on specific versions of 11 GR 2. A fix is included in the 5.0.1 patch set.

    Concerning

    Patrick

  • Marking duplicate records

    Hi gurus of the Oracle,.

    Good morning/afternoon/evening!

    There are several methods to effectively identify duplicate records. e.g. row_number() and group by, but all of these methods to highlight the duplicate record only. Which means that if your table has data such as

    IDNameRoomDate
    1ABC20320/07/2015
    2FGH10920/09/2015
    3HSF20220/08/2015
    4REF20120/08/2015
    5FGH10920/09/2015
    6HSF29124/08/2015

    And I want to find duplicates based on name/room/day

    Most of the queries will give me

    Or the other

    IDNameRoomDate
    5FGH10920/09/2015

    or

    IDNameRoomDate
    2FGH109

    20/09/2015

    They don't give me two files unless I first do a group by (or Row_Number) in an internal query and then try to get the two lines in the outer query. In my view, should not be the way.

    I need a report which highlights the two records only

    IDNameRoomDate
    2FGH10920/09/2015
    5FGH10920/09/2015

    Hope that is clear.

    Thanks in advance!

    Hello

    34MCA2K2 wrote:

    Hi gurus of the Oracle,.

    Good morning/afternoon/evening!

    There are several methods to effectively identify duplicate records. e.g. row_number() and however all these methods to highlight only the duplicate of group by. Which means that if your table has data such as

    ID Name Room Date
    1 ABC 203 20/07/2015
    2 FGH 109 20/09/2015
    3 HSF 202 20/08/2015
    4 REF 201 20/08/2015
    5 FGH 109 20/09/2015
    6 HSF 291 24/08/2015

    And I want to find duplicates based on name/room/day

    Most of the queries will give me

    Or the other

    ID Name Room Date
    5 FGH 109 20/09/2015

    or

    ID Name Room Date
    2 FGH 109

    20/09/2015

    They don't give me two files unless I first do a group by (or Row_Number) in an internal query and then try to get the two lines in the outer query. In my view, that shouldn't be the way...

    Help the ROW_NUMBER analytic function, that you described is probably the easiest and most effective way to get the desired results.

    You can do it without using any kind of subquery (for example, with a self-join or CONNECT BY), but which requires SELECT DISTINCT, which is inefficient.

  • Load ASO duplicate records

    Hello

    I'm loading data in the ASO cube directly from the text file (without using a buffer) and numbers of duplicate records are added, but I need the numbers since the last duplicate record to overwrite all previous records. Is it possible to implement in Essbase ASO?

    You can use the id of the buffer. The 'aggregate_use_last' property can be set to a buffer during initialization it.

    I do not belive there is an option to load the file directly using the command "Import database...". "in this situation.

    Kind regards

    Sunil

  • Check duplicate record all by preventing insertion

    Hello

    I have a scenario where I need to insert records from 20 000 to 30 000 daily in a table that has data in millions.

    Keep inserting a record in duplicate and in the event of any duplicate record, this issue need to be logged in another table.

    I used FORALL except SAVE to allow loading of all records not not duplicate. But with this approach, I am unable to know which record was duplicate or problems in the insertion.

    Also I can't use triggers to connect each record before insertion because I only need the duplicate records. Also, trigger will slow down performance.

    Guide kindly on what approach I should follow to do this (which are also good performance as data are huge).

    Kind regards

    Karki

    Logging error clause does not support dyrect path operations, you must remove the Add indicator to use.

    This is because the logging of errors using autonomous transaction.

    create table test_tomkt_raw
    (c1 varchar2(20),
    c2  varchar2(20),
    c3  varchar2(20));
    
    Table created
    
    Executed in 0,015 seconds
    create table test_mkt
    (c1 varchar2(20),
    c2  varchar2(20),
    c3  varchar2(20));
    
    Table created
    
    Executed in 0,031 seconds
    create table test_mkt_log
    (c1 varchar2(20),
    c2  varchar2(20),
    c3  varchar2(20));
    
    Table created
    
    Executed in 0,078 seconds
    insert into test_tomkt_raw VALUES( 'A','B','C');
    
    1 row inserted
    
    Executed in 0,015 seconds
    insert into test_tomkt_raw VALUES( 'A','B','C');
    
    1 row inserted
    
    Executed in 0 seconds
    insert into test_tomkt_raw VALUES( 'D','E','F');
    
    1 row inserted
    
    Executed in 0 seconds
    insert into test_tomkt_raw VALUES( 'R','BD','AC');
    
    1 row inserted
    
    Executed in 0 seconds
    insert into test_tomkt_raw VALUES( 'AQ','SB','AC');
    
    1 row inserted
    
    Executed in 0,016 seconds
    insert into test_tomkt_raw VALUES( 'AA','BA','CA');
    
    1 row inserted
    
    Executed in 0 seconds
    insert into test_tomkt_raw VALUES( 'A','B','C');
    
    1 row inserted
    
    Executed in 0 seconds
    insert into test_tomkt_raw VALUES( 'D','E','F');
    
    1 row inserted
    
    Executed in 0,016 seconds
    ALTER TABLE test_mkt
    ADD PRIMARY KEY (C1,C2,C3);
    
    Table altered
    
    Executed in 0,015 seconds
    BEGIN
      DBMS_ERRLOG.CREATE_ERROR_LOG('test_mkt');
    END;
    /
    
    PL/SQL procedure successfully completed
    
    Executed in 0,031 seconds
    INSERT /* APPEND */
    INTO TEST_MKT
    SELECT * FROM  TEST_TOMKT_RAW
    LOG ERRORS INTO ERR$_TEST_MKT ('TEST_01') --> This can be a variable on your code to identify this operation
    REJECT LIMIT UNLIMITED
    ;
    
    5 rows inserted
    
    Executed in 0,063 seconds
    INSERT INTO test_mkt_log
    SELECT er.c1, er.c2, er.c3
    FROM  ERR$_TEST_MKT er
    WHERE  er.ora_err_tag$ = 'TEST_01'--> This can be a variable on your code
    AND    er.ora_err_number$ = 1 --> Unique constraint violated
    ;
    
    3 rows inserted
    
    Executed in 0 seconds
    SELECT *
    FROM  TEST_MKT
    ;
    
    C1                  C2                  C3
    -------------------- -------------------- --------------------
    A                    B                    C
    AA                  BA                  CA
    AQ                  SB                  AC
    D                    E                    F
    R                    BD                  AC
    
    Executed in 0,062 seconds
    SELECT *
    FROM  TEST_MKT_LOG
    ;
    
    C1                  C2                  C3
    -------------------- -------------------- --------------------
    A                    B                    C
    A                    B                    C
    D                    E                    F
    
    Executed in 0,047 seconds
    DROP TABLE  test_tomkt_raw;
    
    Table dropped
    
    Executed in 0,032 seconds
    DROP TABLE  test_mkt;
    
    Table dropped
    
    Executed in 0,094 seconds
    DROP TABLE  err$_test_mkt;
    
    Table dropped
    
    Executed in 0,078 seconds
    DROP TABLE  test_mkt_log;
    
    Table dropped
    
    Executed in 0,047 seconds
    
  • Problem joining tables; duplicate records

    I have problems with my request. She joined essentially three tables. I am inside the environment of the Apex, but this problem is with my request. I have three tables:

    JOBS

    Job_Id PK

    Job_Number

    Goal

    Title

    JOB_BUNDLES

    Job_Bundle_Id PK

    Modification_Number

    Justification

    Job_Id FK

    JOB_TASKS

    Job_Task_Id

    Sequence

    Task_Id (values can be either 1,2,3,4,5 or 6)

    Job_Bundle_Id FK

    You can see the stream / connection between each table. A JOB can have several JOB_BUNDLES and one can JOB_BUNDLE have JOB_TASKS a lot. One-to-many relationships

    My query now displays a report of JOB_BUNDLES for a given job, represented in the form:

    SELECT
    Job_Bundle_Id, Modification_Number, Justification, Job_Id
    FROM JOB_BUNDLES JB
    WHERE JB.Job_Id = :P26_Job_Id
    

    The page element, P26_Job_Id represents the Job_Id of the WORK of the table argument. That said, each record JOB_BUNDLE will have JOB_TASKS related records; more specifically, there will be at least a record where JOB. TASKS. Task_Id = 6. This happens only once. I can't get my information from the request that I submitted and the information from the table JOB_TASKS where the Task_Id = 6. I tried to add a JOIN and a WHERE clause, but I still get duplicate records. If anyone has some insight on this issue, it would be greatly appreciated. Thanks in advance.

    What:

    SQL > select b.*

    2, (select t.sequence

    job_tasks 3 t

    4 where t.job_bundle_id = b.job_bundle_id

    5 and t.task_id = 6

    (6) seq

    job_bundles 7 b

    8 where b.job_id = 1;

    JOB_BUNDLE_ID MODIFICATION_NUMBER JUSTIFICATION JOB_ID SEQ

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

    1 0 there is no justification 1 12

    2 that 1 I'm just here for test 1

    3 2 it's the third amendment 1 7

    3 selected lines.

  • Miss an Interface if duplicate records present

    Hi all

    I'm using ODI 11 g.

    I have the flat file interface table where I use IKM as control SQL added, check validation Option, Insert, separate and truncate option as TRUE, control flows as FALSE.

    In my case, suppose I have 10 records out of these 2 records are duplicated. So my interface treats 8 discs to the next level.
    But I want to the failure of the interface if there is duplicate records.

    How to do this?

    Thank you
    Lony

    A set the primary key in the database or ODI?

    Do it in the database if you wish to fail before inserting.
    Do it in ODI and turn control static to true if you want to than his failure after insertion.

    Kind regards
    JeromeFr

  • Group records with time

    Hi all

    This is our requirement.

    We must combine records with time.

    for example: period = 3
    TABLE: XX_SALES
    ---------------------------------------------
    XDATE XQTY
    ---------------------------------------------
    10 5/1/2012
    20 2/5/2012
    3/5/2012 30
    4/5/2012 60
    12 2012/5/7
    8/5/2012 23
    45 8/5/2012
    100 12/5 / 2012
    5/2012/13 55
    5/2012/15 99

    == >
    ---------------------------------------------
    XDATE XQTY
    ---------------------------------------------
    1/5/2012 10-> 5/1/2012 Group (5/1/2012 ~ 3/5/2012)
    2/5/2012 20-> 5/1/2012 Group (5/1/2012 ~ 3/5/2012)
    3/5/2012 30-> 5/1/2012 Group (5/1/2012 ~ 3/5/2012)
    4/5/2012 60-> Group 5/2012/4 (4/5/2012 ~ 2012/5/6) *.
    7/5/2012 12-> Group 5/2012/7 (5/7/2012 ~ 9/5/2012) *.
    8/5/2012 23-> Group 5/2012/7 (5/7/2012 ~ 9/5/2012) *.
    8/5/2012 45-> Group 5/2012/7 (5/7/2012 ~ 9/5/2012) *.
    5/2012/12 100-> Group 5/12/2012 (2012/5/12 ~ 14/5/2012) *.
    13/5/2012 55-> Group 5/12/2012 (2012/5/12 ~ 14/5/2012) *.
    5/15/2012 99-> Group 5/15/2012 (15/5/2012 ~ 5/17/2012) *.

    After amount to combine with period = 3, the result will be
    ---------------------------------------------
    XDATE_G XQTY_G
    ---------------------------------------------
    60 1/5/2012
    4/5/2012 60
    2012/5/7 80
    12/5/2012 155
    5/2012/15 99


    Here's the example script
     
    create table XX_SALES(XDATE DATE, XQTY Number);
    insert into XX_SALES VALUES(to_date('20120501','YYYYMMDD'),10);
    insert into XX_SALES VALUES(to_date('20120502','YYYYMMDD'),20);
    insert into XX_SALES VALUES(to_date('20120503','YYYYMMDD'),30);
    insert into XX_SALES VALUES(to_date('20120504','YYYYMMDD'),60);
    insert into XX_SALES VALUES(to_date('20120507','YYYYMMDD'),12);
    insert into XX_SALES VALUES(to_date('20120508','YYYYMMDD'),23);
    insert into XX_SALES VALUES(to_date('20120508','YYYYMMDD'),45);
    insert into XX_SALES VALUES(to_date('20120512','YYYYMMDD'),100);
    insert into XX_SALES VALUES(to_date('20120513','YYYYMMDD'),55);
    insert into XX_SALES VALUES(to_date('20120515','YYYYMMDD'),99);
     
    We can solve this problem by using the loop now:
    to find the XDATE_G and it's rank in the loop and the XQTY in the range of the sum.
    DECLARE
      V_DATE_FROM DATE := NULL;
      V_DATE_TO   DATE := NULL;
      V_QTY_SUM   NUMBER := 0;
      CURSOR CUR_DATE IS
        SELECT DISTINCT XDATE FROM XX_SALES ORDER BY XDATE;
    BEGIN
      FOR REC IN CUR_DATE LOOP
        IF V_DATE_TO IS NULL OR REC.XDATE > V_DATE_TO THEN
          V_DATE_FROM := REC.XDATE;
          V_DATE_TO   := REC.XDATE + 3 - 1;
          SELECT SUM(XQTY)
            INTO V_QTY_SUM
            FROM XX_SALES
           WHERE XDATE >= V_DATE_FROM
             AND XDATE <= V_DATE_TO;
          DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_DATE_FROM, 'YYYYMMDD') ||
                               '-----qty: ' || TO_CHAR(V_QTY_SUM));
        END IF;
      END LOOP;
    END;
    Is it possible to solve this problem by using analyze sql?


    Thanks in advance,
    Best regards
    Zhxiang

    Published by: zhxiangxie on April 26, 2012 14:41 fixed the grouping expected data

    There was an article about a similar problem in Oracle Magazine recently:

    http://www.Oracle.com/technetwork/issue-archive/2012/12-Mar/o22asktom-1518271.html

    See the section on the 'grouping beaches '. They needed a total cumulative who started once the total reaches a certain amount.

    You need a total cumulative which starts again when the date changes to group and the dates of beginning and end of each group must be determined dynamically.

    This can be done with the analytical functions.

    Here is a solution-based 'code listing 5', the solution MODEL, which is recommended in the article.

    SELECT FIRST_DATE, SUM(XQTY) SUM_XQTY FROM (
      SELECT * FROM xx_sales
      MODEL DIMENSION BY(ROW_NUMBER() OVER(ORDER BY XDATE) RN)
      MEASURES(XDATE, XDATE FIRST_DATE, XQTY)
      RULES(
        FIRST_DATE[RN > 1] =
          CASE WHEN XDATE[CV()] - FIRST_DATE[CV() - 1] >= 3
          THEN xdate[cv()]
          ELSE FIRST_DATE[CV() - 1]
          END
      )
    )
    GROUP BY first_date ORDER BY first_date;
    
    FIRST_DATE            SUM_XQTY
    --------------------- --------
    2012/05/01 00:00:00         60
    2012/05/04 00:00:00         60
    2012/05/07 00:00:00         80
    2012/05/12 00:00:00        155
    2012/05/15 00:00:00         99
    

    If you 9i, there is no function model. In this case, I can give you a solution using START WITH / CONNECT BY that does not work as well.

  • ROW_NUMBER and duplicate records

    Hello

    Tried to delete duplicate records. The code below works, but would remove all, rather than simply the > #1 records:

    (SELECT academic_period, load_week, sub_academic_period, person_uid, course_number,
    course_reference_number, rowid that RID, row_number() over (partition of)
    academic_period, load_week, sub_academic_period, person_uid, course_number,
    order of course_reference_number of academic_period, load_week, sub_academic_period,
    person_uid, course_number, course_reference_number)
    Of THE cea
    WHERE (academic_period, load_week, sub_academic_period, person_uid, course_number,)
    IN course_reference_number)
    (SELECT academic_period, load_week, sub_academic_period, person_uid, course_number,
    course_reference_number
    Of THE cea
    GROUP of academic_period, load_week, sub_academic_period, person_uid, course_number,
    course_reference_number
    HAVING COUNT (*) > 1))


    If I try to put 'rn' and rn > 1, I get ora-00933: Sql not correctly completed command

    SELECT academic_period, load_week, sub_academic_period, person_uid, course_number,
    course_reference_number, rowid that RID, row_number() over (partition of)
    academic_period, load_week, sub_academic_period, person_uid, course_number,
    order of course_reference_number of academic_period, load_week, sub_academic_period,
    person_uid, course_number, course_reference_number): the nurse
    Of THE cea
    WHERE (academic_period, load_week, sub_academic_period, person_uid, course_number,)
    IN course_reference_number)
    (SELECT academic_period, load_week, sub_academic_period, person_uid, course_number,
    course_reference_number
    Of THE cea
    GROUP of academic_period, load_week, sub_academic_period, person_uid, course_number,
    course_reference_number
    After HAVING COUNT (*) > 1)
    and rn > 1

    I tried to remove as"rn" and make "rn" and "rn", which gave me an error of syntax also. The '' rn > 1 and '' clause gets an error of syntax also. I gone through a bunch of different Web sites. All of this indicates the syntax I am using will work. However, any query I run into a TOAD, always error when I include the 'rn > 1.

    Any ideas? Thank you!

    Victoria

    You mix two ways to identify duplicates.

    One way is HAVING:

    SELECT academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number
    FROM cea
    GROUP BY academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number
    HAVING COUNT(*) > 1)
    

    That tells you just what combinations of your group are more than once.

    Another way is to analytical functions:

    select *
    from (
      SELECT academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number
             count(*) over (partition by academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number) cnt
      FROM cea
    )
    where cnt > 1
    

    This will all return duplicate records - if some combinations has three duplicates, then this will return all three lines.

    If you use the ROW_NUMBER() place COUNT() analytical analytical function, you get this:

    select *
    from (
      SELECT academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number
             row_number() over (partition by academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number) rn
      FROM cea
    )
    where rn > 1
    

    All of these files without duplicates will get rn = 1. Those with duplicates gets rn = 1, rn = 2... If rn > 1 Gets all "unnecessary" records - the ones you want to remove.

    If a deletion might look like:

    delete cea
    where rowid in (
      select rid
      from (
        SELECT ROWID as rid,
               row_number() over (partition by academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number) rn
        FROM cea
      )
      where rn > 1
    )
    

    Or if you want to manually inspect before you delete ;-):

    select *
    from cea
    where rowid in (
      select rid
      from (
        SELECT ROWID as rid,
               row_number() over (partition by academic_period, load_week, sub_academic_period, person_uid, course_number, course_reference_number) rn
        FROM cea
      )
      where rn > 1
    )
    

    In another answer, you can find a way to remove duplicates with HAVING.
    The point is that do you it either with or with ROW_NUMBER() - not both HAVING ;-)

  • Delete several duplicate records

    Hi all
    My table has multiple records, and I want to keep only the first record in the table. Can someone help me on this. I tried following things:
    SELECT * FROM the tab
    WHERE ROWID in (SELECT MAX (ROWID) <>
    IN tab B
    WHERE B.col1 = A.col1
    AND B.col2 = A.col2
    )
    This remove the last duplicate record.
    I also tried
    SELECT * FROM the tab
    WHERE ROWID > (SELECT MIN (ROWID)
    IN tab B
    WHERE B.col1 = A.col1
    AND B.col2 = A.col2
    )
    This was removed and the first record to some places, but it has worked in some places. I am not able to understand why it was wrong in some places.
    I'm working on Oracle 10 g
    Please suggest.

    Thank you.

    Duplicate records mean reproduce according to specific columns (in your example, col1 and col2).
    If you want the trial to be held, you must determine all first according to what, if you mean the first entered record (which is not safe, and you should rely on an explicit column).
    You can use

    SELECT *
      FROM tab A
     WHERE ROWID NOT IN (SELECT MIN (ROWID)
                           FROM tab B
                          WHERE B.col1 = A.col1 AND B.col2 = A.col2)
    

    or use a column

    SELECT *
      FROM tab A
     WHERE col3 NOT IN (SELECT MIN (col3)
                           FROM tab B
                          WHERE B.col1 = A.col1 AND B.col2 = A.col2)
    

    Saad,

Maybe you are looking for