Delete query to delete records from multiple tables

All,

I need a delete query that will delete the records from the tables. Please see the structure of the table & below
CREATE TABLE TEMP1 (ID NUMBER(10),NAME VARCHAR2(40),CLASS VARCHAR2(40),COLLEGE VARCHAR2(40));
CREATE TABLE TEMP2 (ID NUMBER(10),CITY VARCHAR2(40),STATE(40));

INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (1000,'SAM','CS','UNIV_1');
INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (2000,'RIO','CS','UNIV_1');
INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (3000,'CHRIS','CS','UNIV_1');
INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (4000,'ALEX','CS','UNIV_1');

INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (1000,'Auburn','NY');
INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (2000,'Ithaca','NY');
INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (3000,'Mount Vernon','NY');
INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (4000,'Port Jervis','NY');
Now, I need to delete the records in these tables where the ID is '2000' by using a single delete query. Is this possible? This may be a newbie question. Help, please.

"using a single request deletion. Is this possible?

Nope.
You can insert into multiple tables by using a single query, INSERT ALL job, but you cannot delete more than one table using a single query.

Tags: Database

Similar Questions

  • Delete records from a table of forms

    Oracle forms6i
    Hai All

    I use forms6i and my need is I have generated a forms and the output is displayed through tables and I need to delete all the records from the table of my forms when executing next time pls tell me

    Concerning

    Srikkanth.M

    Hello

    Please try something like that.

    Begin
    Delete From Master_Tbl Cascade;
    forms_ddl('Commit');
    End;
    

    Sarah

  • Use with need to collect in bulk to insert records from multiple tables

    Hello

    I plsql record type with several tables with multiple columns. so when I used bulk collect with education for ALL. I want to insert records in multiple tables.

    Please give me suggestions.

    ForAll is designed to be used with a single DML statement, which may include dynamic SQL statements. However, I do not know what advantage this will give you your list iteration save several times, one for each table - especially since there is an air show with SQL dynamic.

    Example 1 (dynamic SQL):

    begin

      ...

      forall i in vRecList.First..vRecList.Last
        execute immediate '
        begin
          insert into Table1 (Col1, Col2, Col3) values (:1, :2, :3);
          insert into Table2 (Col1, Col2, Col3) values (:1, :2, :3);
        end;' using vRecList(i).Col1, vRecList(i).Col2, vRecList(i).Col3;
    end;

    Another approach that I should work (but not tested) is using to insert all the Scriptures and based record inserts, but you need to try on your version of Oracle forall has changed between the versions.  In this case vRecList must be compatible with the Table % ROWTYPE and Table2% ROWTYPE type.


    Example 2 (insert all):

    begin

      ...

      forall i in vRecList.First..vRecList.Last

        insert all

          into Table1 values vRecList(i)
          into Table2 values vRecList(i)
        select 1 from dual;

    end;

  • How to delete records from a table?

    It comes to my table structure:
    create table BILLS
    (
      bill_id    VARCHAR2(20),
      trx_no     VARCHAR2(20),
      item_code  VARCHAR2(3),
      amount     NUMBER,
      item_id    NUMBER,
      invoice_dt DATE
    )
    Here are some insert statements to populate the table. *(About a 100 of them, please Bear with me) *.
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104173960', '910873', '002', 432, 351, to_date('04-03-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104209800', '910873', '002', 432, 351, to_date('04-04-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104212747', '263156', '039', 230, 351, to_date('01-04-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104269414', '263156', '039', 230, 351, to_date('01-06-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104360446', '263156', '039', 230, 351, to_date('01-09-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104577673', '910873', '002', 432, 351, to_date('04-04-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104608668', '910873', '002', 432, 351, to_date('04-05-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104611586', '263156', '039', 230, 351, to_date('01-05-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104642560', '910873', '002', 432, 351, to_date('04-06-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104699154', '910873', '002', 432, 351, to_date('04-08-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104820820', '263156', '039', 230, 351, to_date('01-12-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104826028', '910873', '002', 432, 351, to_date('04-12-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104850631', '910873', '002', 432, 351, to_date('04-01-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104885554', '263156', '039', 230, 351, to_date('01-02-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104926901', '910873', '002', 432, 351, to_date('04-03-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104936656', '263156', '', 15, 247, null);
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104996320', '263156', '039', 230, 351, to_date('01-05-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105030104', '263156', '039', 230, 351, to_date('01-06-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105176803', '910873', '002', 432, 351, to_date('04-10-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105217998', '910873', '002', 432, 351, to_date('04-11-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105253306', '263156', '039', 230, 351, to_date('01-12-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105280152', '263156', '039', 230, 351, to_date('01-01-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105318072', '910873', '002', 432, 351, to_date('04-02-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105449712', '910873', '002', 432, 351, to_date('04-06-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105579048', '910873', '002', 432, 351, to_date('04-10-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105611201', '263156', '039', 230, 351, to_date('01-11-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105679991', '263156', '011', 196.56, 351, to_date('06-01-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105686749', '910873', '002', 432, 351, to_date('04-01-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105816473', '910873', '002', 432, 351, to_date('04-05-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105846525', '263156', '011', 230, 351, to_date('01-06-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105778111', '910873', '002', 432, 351, to_date('04-04-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104958496', '910873', '002', 432, 351, to_date('04-04-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105143695', '910873', '002', 432, 351, to_date('04-09-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104176755', '263156', '039', 230, 351, to_date('01-03-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104365552', '910873', '002', 432, 351, to_date('04-09-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104646837', '263156', '039', 230, 351, to_date('01-06-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104763596', '910873', '002', 432, 351, to_date('04-10-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104936656', '263156', '', 15, 247, null);
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105510930', '263156', '039', 230, 351, to_date('01-08-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104302780', '263156', '039', 230, 351, to_date('01-07-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104793590', '263156', '039', 230, 351, to_date('01-11-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104238583', '910873', '002', 432, 351, to_date('04-05-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105779115', '263156', '011', 230, 351, to_date('01-04-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104394481', '263156', '039', 230, 351, to_date('01-10-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105144934', '263156', '039', 230, 351, to_date('01-09-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105342823', '263156', '039', 230, 351, to_date('01-03-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105747780', '910873', '002', 432, 351, to_date('04-03-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105517258', '910873', '002', 432, 351, to_date('04-08-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105617909', '910873', '002', 432, 351, to_date('04-11-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104480711', '910873', '002', 432, 351, to_date('04-01-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105845480', '910873', '002', 432, 351, to_date('04-06-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105349031', '910873', '002', 432, 351, to_date('04-03-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105382599', '263156', '039', 230, 351, to_date('01-04-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104423263', '263156', '039', 230, 351, to_date('01-11-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104482370', '263156', '039', 230, 351, to_date('01-01-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104892872', '910873', '002', 432, 351, to_date('04-02-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105071771', '263156', '039', 230, 351, to_date('01-07-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105716829', '910873', '002', 432, 351, to_date('04-02-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105251149', '910873', '002', 432, 351, to_date('04-12-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105420465', '910873', '002', 432, 351, to_date('04-05-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105547036', '910873', '002', 432, 351, to_date('04-09-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105450806', '263156', '039', 230, 351, to_date('01-06-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105178143', '263156', '039', 230, 351, to_date('01-10-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105648407', '910873', '002', 432, 351, to_date('04-12-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105718070', '263156', '011', 230, 351, to_date('01-02-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104735083', '910873', '002', 432, 351, to_date('04-09-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105748707', '263156', '011', 230, 351, to_date('01-03-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104570555', '263156', '039', 230, 351, to_date('01-04-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105480249', '910873', '002', 432, 351, to_date('04-07-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104799512', '910873', '002', 432, 351, to_date('04-11-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105036878', '910873', '002', 432, 351, to_date('04-06-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105413781', '263156', '039', 230, 351, to_date('01-05-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105548204', '263156', '039', 230, 351, to_date('01-09-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104510445', '910873', '002', 432, 351, to_date('04-02-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104545120', '263156', '039', 230, 351, to_date('01-03-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104700608', '263156', '039', 230, 351, to_date('01-08-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104765006', '263156', '039', 230, 351, to_date('01-10-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105111984', '910873', '002', 432, 351, to_date('04-08-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105310993', '263156', '039', 230, 351, to_date('01-02-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105481415', '263156', '039', 230, 351, to_date('01-07-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105210719', '263156', '039', 230, 351, to_date('01-11-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105809981', '263156', '011', 230, 351, to_date('01-05-2011', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104328833', '910873', '002', 432, 351, to_date('04-08-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104511904', '263156', '039', 230, 351, to_date('01-02-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105278905', '910873', '002', 432, 351, to_date('04-01-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104421567', '910873', '002', 432, 351, to_date('04-11-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104851866', '263156', '039', 230, 351, to_date('01-01-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105649424', '263156', '039', 230, 351, to_date('01-12-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104729022', '263156', '039', 230, 351, to_date('01-09-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105070358', '910873', '002', 432, 351, to_date('04-07-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104299829', '910873', '002', 432, 351, to_date('04-07-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104920099', '263156', '039', 230, 351, to_date('01-03-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104266551', '910873', '002', 432, 351, to_date('04-06-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104994904', '910873', '002', 432, 351, to_date('04-05-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104910999', '263156', '', 15, 247, null);
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104241418', '263156', '039', 230, 351, to_date('01-05-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104960203', '263156', '039', 230, 351, to_date('01-04-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105381371', '910873', '002', 432, 351, to_date('04-04-2010', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104542458', '910873', '002', 432, 351, to_date('04-03-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104670160', '910873', '002', 432, 351, to_date('04-07-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105105026', '263156', '039', 230, 351, to_date('01-08-2009', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104392347', '910873', '002', 432, 351, to_date('04-10-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104451005', '910873', '002', 432, 351, to_date('04-12-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104453960', '263156', '039', 230, 351, to_date('01-12-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104671563', '263156', '039', 230, 351, to_date('01-07-2008', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('104331181', '263156', '039', 230, 351, to_date('01-08-2007', 'dd-mm-yyyy'));
    
    insert into BILLS (BILL_ID, TRX_NO, ITEM_CODE, AMOUNT, ITEM_ID, INVOICE_DT)
    values ('105580192', '263156', '039', 230, 351, to_date('01-10-2010', 'dd-mm-yyyy'));
    It comes to my select statement.
    SELECT 
           Trx_No,
           Item_Code,
           Amount,
           Item_Id,
           MAX(Invoice_Dt)
      FROM Bills
     GROUP BY 
              Trx_No,
              Item_Code,
              Amount,
              Item_Id
    I want to remove the lines that are extracted from my select statement. What is the best way to achieve this?

    SELECT query sets.

    She literally takes

    delete from bills
     where (Trx_No,Item_Code,Amount,Item_Id,Invoice_Dt) in (select Trx_No,Item_Code,Amount,Item_Id,MAX(Invoice_Dt)
                                                              FROM Bills
                                                             GROUP BY Trx_No,Item_Code,Amount,Item_Id
                                                           )
    

    Concerning

    Etbin

  • How to delete records from a table that has a composite unique key duplicate

    Hello
    I get the customer data from various sources in the staging of the table where I insert in the database table where the combination of two columns is considered as a unique key. But there is a possibility of duplicates. How to find duplicates in a SQL or pl/sql

    Thank you
    Manoi.

    Kassa,

    You can see the duplicates by using the following query...

    sql> select * from temp_rajesh;
    
          COL1       COL2 MESSAGE
    ---------- ---------- ------------------
           100        200 message
           100        200 message2
           300        400 message3
           400        500 message 4
    
    sql> select col1, col2, count(*)
      2     from temp_rajesh
      3       group by col1, col2
      4         having count(*) > 1;
    
          COL1       COL2   COUNT(*)
    ---------- ---------- ----------
           100        200          2
    

    -If in the case of duplicate records, you should see only the duplicates (according to some timestamp etc., you can use the functinon row_number analytic..)

      1  select col1, col2 from (
      2  select col1, col2,
      3         row_number() over (partition by col1, col2
      4                            order by message) rn
      5    from temp_rajesh)
      6*   where rn > 1
    sql> /
    
          COL1       COL2
    ---------- ----------
           100        200
    

    In the above example, I use message to order, you can replace it with activity_timestamp or the insertd_date according to your logic... when there are two records... one that you choose to duplicate.

    Thank you
    Rajesh.

    Published by: Rajesh Chamarthi on November 20, 2009 12:05 AM (added for example)

  • Deleting records from a table and trying to retrieve those

    Hello
    is it possible to recover the table deleted after validation of the track file, if so how? Once again I have to synchronize back to the database once the table is retrieved.

    Reverse GoldenGate utility.

    details on this forum.
    Reverse GoldenGate utility
    Golden Gate can be a lever to make point in time recovery for MySql?

  • Delete records from sys.aud$ stored procedure

    We have a stored procedure that attempts to move the records from the table of sys.aud$ to a history table (in order to keep sys.aud$ to a more reasonable size, I guess - full disclosure, I have not written this proc). Base flow is:
    Select count (*) in the number of lines of sys.aud$
    If {(rowcount > 1000)
    copy all rows in sys.aud$ in the history table
    remove from sys.aud$
    }

    I says this proc used to work perfectly in a troubled past (I'm new on the client) but now has not worked for a while. When we try to compile the proc, we get the error
    "table or view does not exist", and the line is the "deletion of sys.aud$. The line "select count (*) from sys.aud$ ' seems to cause no problems, but the proc does not compile as is. If I comment out the line "remove from sys.aud$", however, the proc compiles very well.

    Confusingly, if I log in as the same account that owns this proc, I can run both the count (*) select from sys.aud$ AND remove clauses sys.aud$ with no complaint at all (by modifying slightly to work with 1 single record at a time, of course), but I can't seem the same to compile in a stored proc.

    I guess that it is related permissions? Can someone point me to the permissions of the owner needs to be able to remove from sys.aud$ in a stored procedure? Or is there something else that needs to be done here? Pointers much appreciated.

    Thank you.

    956928 wrote:
    We have a stored procedure that attempts to move the records from the table of sys.aud$ to a history table (in order to keep sys.aud$ to a more reasonable size, I guess - full disclosure, I have not written this proc). Base flow is:
    Select count (*) in the number of lines of sys.aud$
    If (rowcount 1000 >) {}
    copy all rows in sys.aud$ in the history table
    remove from sys.aud$
    }

    I says this proc used to work perfectly in a troubled past (I'm new on the client) but now has not worked for a while. When we try to compile the proc, we get the error
    "table or view does not exist", and the line is the "deletion of sys.aud$. The line "select count (*) from sys.aud$ ' seems to cause no problems, but the proc does not compile as is. If I comment out the line "remove from sys.aud$", however, the proc compiles very well.

    Confusingly, if I log in as the same account that owns this proc, I can run both the count (*) select from sys.aud$ AND remove clauses sys.aud$ with no complaint at all (by modifying slightly to work with 1 single record at a time, of course), but I can't seem the same to compile in a stored proc.

    I guess that it is related permissions? Can someone point me to the permissions of the owner needs to be able to remove from sys.aud$ in a stored procedure? Or is there something else that needs to be done here? Pointers much appreciated.

    Thank you.

    acquired through ROLE privileges are NOT applicable within the named PL/SQL procedures.

    GRANT DELETE ON SYS. AUD$ ;

  • To create an interactive report in the apex by selecting from multiple tables

    Hi, I am creating an interactive report by selecting from multiple tables.

    SELECT w.FIRST_NAME as name, w.SURNAME as name, i.ROAD Road, i.DATE_OF_INC as DATE_OF_INC, S.STATEMENT as a STATEMENT OF Declaration

    JOIN THE

    WITNESS w

    ON w.witness_id = s.FK1_WITNESS_ID

    JOIN THE

    Incident I have

    WE

    i.incident_no = w.FK1_INCIDENT_NO

    JOIN THE

    user_station ps

    ON ps.station_id = i.nearest_station_id

    JOIN THE

    the user in.

    WE

    in. STATION_ID = ps.station_id

    WHERE po.officer_id = 1

    by I continue to encounter this error "the report query requires a unique key to identify each row. The supplied key cannot be used for this query. Please change the report attributes to define a unique key column. "ORA-01445: cannot select ROWID from where sample, a join without key preserved table view '

    So I googled around and found that in the attibutres tables report, I need to change the "LINK" COLUMN so first, I changed "Link to custom target", but the report is so I changed it to "Exclude link Clolumn" again, the report didn't report and I STILL got a blank page with only the tabs.

    I wonder you can not create a report by selecting from multiple tables?

    If you can please I need your help.

    Thank you

    You can, but in this case, it might be easier to build your report tables that are joined Oracle views and then build your report out of the newly built sight...

    Or wrap a selection around your selection with joins, and then make the where clause on the external selection...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • Update multiple columns from multiple tables in a single UPDATE request

    Hello

    I'm trying to figure if I'm heading in the right direction.

    I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.

    Scenario 1

    UPDATE Table2, Table 3
    SET T2.Column1 = T1.Column1 
    ,T2.Column2 = T1.Column2
    ,T3.Column2 = T1.Column2
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T1.id = T2.id
    and T1.id = T3.id
    
    

    Scenario 2

    UPDATE Table3
    SET T3.Column1 = T1.Column1 
    T3.Column2 = T1.Column2
    ,T3.Column3 = T2.Column3
    ,T3.Column4 = T2.Column4
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T3.id = T1.id
    and T3.id = T2.id
    
    

    Hello

    For scenario 1, you must write separate instructions UPDATE table2 and table3.

    To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.

    ENGAGE only when two tables have been changed.

    You can write a procedure or an INSTEAD OF trigger to do all this.

    For scenario 2, you can reference many tables that you need when new table3.  It might be more efficient and simpler to use the MERGER rather than UPDATED.  For example:

    MERGE INTO table3 dst

    WITH THE HELP OF)

    SELECT t1.id

    t1.column1

    t1.column2

    t2.column3

    t2.column4

    FROM table1 t1

    JOIN table2 t2 ON t1.id = t2.id

    )             src

    WE (dst.id = src_id

    WHEN MATCHED THEN UPDATE

    SET dst.column1 = src.column1

    dst.column2 = src.column2,

    dst.column3 = src.column3,

    dst.column4 = src.column4,

    ;

  • help in registration of the records from two tables

    HI: I have two tables joined the first field. The field is the primary key in the first table. Need help listing records from both tables with each a line/record results.
    create table EVENTS (
    event_key varchar2(64) primary key,
    event_description varchar2(64),
    create_time int
    );
    
    
    create table EVENT_UPDATES (
    event_key varchar2(64) NOT NULL ,
    update_description varchar2(64),
    update_time int
    );
    
    
    insert into EVENTS values('Event1', 'This is event1', 1);
    insert into EVENT_UPDATES values('Event1', 'Ticket created', 3);
    insert into EVENT_UPDATES values('Event1', 'Event cleared', 10);
    insert into EVENTS values('Event2', 'This is event2', 4);
    insert into EVENT_UPDATES values('Event2', 'Ticket created', 6);
    insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);
    I want to print each record in the table of EVENTS such as a line and the corresponding records in EVENT_UPDATES as a line like this record
    Event1   1     This is event1
                3     Ticket created
                10   Event cleared
    Event2   4     This is event2
                6     Ticket created
                8     Event cleared
    TIA
    Ravi
    select  case weight
              when 1 then event_key
            end key,
            time_val,
            description
      from  (
              select  event_key,
                      create_time time_val,
                      event_description description,
                      1 weight
                from  events
             union all
              select  event_key,
                      update_time,
                      update_description,
                      2 weight
                from  event_updates
            )
      order by event_key,
               weight
    /
    
    KEY          TIME_VAL DESCRIPTION
    ---------- ---------- -------------------------
    Event1              1 This is event1
                        3 Ticket created
                       10 Event cleared
    Event2              4 This is event2
                        6 Ticket created
                        8 Event cleared
    
    6 rows selected.
    
    SQL> 
    

    SY.

  • Impossible to delete the record from the table using the form

    I have a stored procedure (function, actually) that allows an administrator to manually delete a record in a table.

    When I call my form there will be no effect. The record remains in the table.

    In both cases, I connect to the database to the same user.

    I am able to call a test function in the database which returns a field in the record, so I think I can at least communicate with and retrieve results from the database using a stored function. As soon as I approach him "select" "delete from", no luck.

    If I try to run the SQL in my form with a statement of FORMS_DDL, it seems to run smoothly when I not in the code in the debugger, but it had no effect. FORMS_SUCCESS reports TRUE if DBMS_ERROR_TEXT has the following: ORA-01403: no data found. I don't know how the DBMS_ERROR_TEXT is that FORMS_SUCCESS is not set to FALSE.

    Any ideas as to why I am unable to remove using my form but can when you call the function registered directly/manually?

    Using Oracle Forms & DB 10.0.2.0.1.

    Patrick,

    After each Insert / Update / Delete statement, you have to COMMIT . Then only it will be in select statements.

    Kind regards

    Manu.

  • How to restore deleted records in another table in the oracle 10g database...

    Hi all

    I want to restore deleted records in a particular table in the other table

    Suppose that:

    I make a request

    delete from emp

    where deptno = 30;

    now, I won't restore deptno = 30 records in the other table, let's say table emp1

    can someone let me know how to do it?

    Thank you...

    This is what flashback query is for:

    orclz > conn scott/tiger

    Connected.

    orclz > select count (*) emp;

    COUNT (*)

    ----------

    14

    orclz > delete from emp where deptno = 30;

    6 deleted rows.

    orclz > commit;

    Validation complete.

    orclz > create table deleted30 in select * from emp to the timestamp (systimestamp - 5/1440) where deptno = 30;

    Table created.

    orclz > select count (*) in the deleted30;

    COUNT (*)

    ----------

    6

    orclz >

  • Delete rows from the table

    Hello

    10G

    A custom table is to have 5000 documents, I need to have everything 100 records in the table and delete the rest of them.
    could you suggest...

    Thank you
    Tim
    delete table_name where rowid not in (select rowid from table_name where rownum <101);
    
  • Storage from multiple tables in one MySQL query

    So I would like, with a single MySQL query, extract data from a table (say 15 rows of data) and then extract data from another table (lets say another 15 ranks) and who joined the first, so that I can view and paginate a single list (of 30 rows now).  I don't think that a join is what I'm looking for, because I want the second list should be annexed to the first and not mixed in.  I would just use different queries, but I already have the paging function implemented for a single set of records, and implementation with two (where the second begins when the first leaves) seems daunting. However, if you have any tips on one, they would really help.

    Thank you

    You need to use a UNION to join the two select statements. The number of columns and the data types of each selection must match.

  • To load multiple records in multiple tables from target

    I have read several records as a set of a file flat source unique and load in the different target tables.
    I have to read 3 discs as a game and load different targets in 3 tables and read another 3 disks as a game and load in the previous tables 3 target and it will
    until all of the records from flat file are loaded.
    The structure of the file is as follows:
    Header record
    Record line
    Record distribution
    Header record
    Record line
    Record distribution
    ....
    ....
    ... ...

    Read the header record and load into the target table
    Record line to read and load in the target B table
    Record Distribution to read and load in the target C table
    -Repeat the same steps until all records are read and loaded into the target tables.

    I would be grateful if anyone can suggest the best approach to the design of interface/package and error conditions to manage?

    Thank you
    RAM

    Hello

    in this case you must create the data store depending on a model "Flat file".
    For example, create 3 store data with the same resource (file), but change the column definition
    Usually on the first column, set the 'model' for each specific format "variable code.

    You create 3 interfaces and load your target (for example database table)

    Concerning

    Stéphane

Maybe you are looking for

  • Two monitors on hp pavilion slimline s3700y pc desktop?

    I have a hp pavilion slimline s3700y desktop pc. is it possible that it can support two monitors?

  • Yellow Device Manager!

    OK, so I'm missing some drivers on this device of 9470 m EliteBook Folio: Base system device: Properties: Hardware ID: PCI\VEN_197B & DEV_2392 & SUBSYS_18DF103C & REV_30 PCI\VEN_197B & DEV_2392 & SUBSYS_18DF103C PCI\VEN_197B & DEV_2392 & CC_088000 PC

  • WINDOWS UPDATE ERROR 8007EFE

    Hello, I have a problem. Can someone help me? When I try to update still shows the error 8007EFE. I have donot do? can someone guide me? Thank you. e.

  • Can't turn on clip

    When I connect to my computer, I have the clip shows as load and I can see all my music, and the battery shows 98%. But when I disconnect, the clip will not illuminate. I tried holding the power switch for 15 seconds, but this good dd Any ideas on wh

  • HP dc 7800 how can I install the driver for serial port pci Windows 8.1

    HP dc 7800 how can I install the driver for serial port pci Windows 8.1 Please help