PL/SQL :: To Delete Child Records Manually Without Using Oracle Delete Cascade

Oct 9, 2012

I have to write a procedure that accepts schema name, table name and column value as parameters....I knew that i need to use metadata to do that deleting manually.

View 9 Replies


ADVERTISEMENT

SQL & PL/SQL :: Delete Records From Child And Parent Table

Jan 2, 2013

I want to delete records from parent table which are less than 2 years. Before deleting records from parent table we have to delete records from child table. How can we delete those records. I don't want to use ON DELETE CASCADE.

MASS_MASTER --parent table.
MASS_CHILD --child table.

The below query is used to delete records from parent table.

DELETE FROM mass_master WHERE last_date<=ADD_MONTHS(sysdate,-24);

The child table MASS_CHILD is not having last_date column. provide me the query to delete same records from child table.

View 21 Replies View Related

On Delete Cascade

Mar 27, 2007

We have a bunch of tables with FKs but we do not have the 'on delete cascade' option on these FKs. If I want to delete records in the database do I have to write delete statements for each table starting with the lowest child or is there a cascade option I can use with the delete statement?

View 1 Replies View Related

PL/SQL :: On Delete Cascade?

Oct 27, 2013

, we have used alter table to change the constraint in on delete cascade. there is two option. what is different between both ofthem. Example:1)Alter table t3 add constraint t2_F foreign key (id) references t2(id,column2,column3) on delete cascade ;or2)Alter table t3 add constraint t2_F foreign key (id) references t2 on delete cascade ; 

know first one that particular column will set to on delete cascade.What is the use of second one in this case we are not using column name in "foreign key (id) references t2 on delete cascade ;" 

View 9 Replies View Related

SQL & PL/SQL :: Constraints And Delete Cascade Events

May 9, 2011

I have a table with 2 defined FK constraints which fires delete cascade events.

I want to deny deletions when the event is fired from one of the tables and permit them when the event is fired from the other table.

Is it possible?

Is any way to solve which table fires the event?

View 2 Replies View Related

SQL & PL/SQL :: Parent And Child Table - Delete Row

May 18, 2010

I have a parent table and child table. I want a row to be deleted from the parent table which is referenced by a child row. Is there a way to achieve this. I dont have permission to re create the table or alter the table using delete cascade option. Is there a way to do it in sql.

SQL> create table t1(a number primary key, b number);
SQL> create table t2(c number, d number references t1(a));
SQL> insert into t1 values(1,2);
SQL> insert into t1 values(2,3);
SQL> insert into t1 values(3,4);
SQL> insert into t2 values(10,3);
SQL> insert into t2 values(20,2);
SQL> delete from t1 where a=2;
delete from t1 where a=2
*

ERROR at line 1:
ORA-02292: integrity constraint (CISBATCH.SYS_C00763501) violated - child
record found

View 11 Replies View Related

SQL & PL/SQL :: Delete - Parent / Child Relationship

May 22, 2012

I have a DB that has one parent table with many child tables. I would like to delete all records(child - parent) based upon a particular "net_id". I have three versions that "seem" to work BUT I'd like to use "version2" because I want to go to the parent one time(for the parent delete I just made it simple for me) only and be able to delete the child record(s) from the child table(s). I want to achieve this w/o using triggers...

My question: Is version2 an "ok" way to delete child records or should I try another method(version1 or 3)??

create table PARENT
(
event_id NUMBER,
event_title VARCHAR2(50),
net_id VARCHAR2(16)
);

--truncate table parent;
insert into parent
(event_id, event_title, net_id)
values
(1, 'title1', 'CURLY');
[code]...

View 10 Replies View Related

SQL & PL/SQL :: How To Delete A Data Which Is Related To Many No Of Child Table

Apr 13, 2012

how to delete a data which is related to many no of child table and according to setnull and casecad by using subprogram?

View 6 Replies View Related

SQL & PL/SQL :: Procedure To Delete Records / Count Number Of Records Has Been Deleted

Feb 21, 2011

I have written the following PL/SQL procedure to delete the records and count the number of records has been deleted.

CREATE OR REPLACE PROCEDURE Del_emp IS
del_records NUMBER:=0;
BEGIN
DELETE
FROM candidate c
WHERE empid in
(select c.empid
from employee e,
candidate c
where e.empid = c.empid
and e.emp_stat = 'TERMINATED'
);
[code]....

View 6 Replies View Related

SQL & PL/SQL :: Delete All Records From A Recordset In One Go?

Jul 3, 2010

I am selecting around 10000 records in a recordset using an sql query.I need to delete these 10000 records from 10 different tables as each of the table have these records.I can use a FOR Loop for each record one by one to delete these 10K records from each tabel but i was wondering if i can delete there 10K in one go so that the program would Loop Only once rather thatn 10K times.

Mine Delete code looks like:

if x.first is not null then
for i in x.first..x.last loop
delete tbl_A where trade_id = x(i).trade_id;
delete tbl_B where trade_id = x(i).trade_id;

[code]...

Where x is the recordset having around 10K records.Is there any way i can run the loop only once rather than one by one for 10K times.

View 5 Replies View Related

Forms :: Delete Records

May 1, 2013

Sqty is sold qty , rqty is return qty , sdate is sold date , vno is billno .

When we enter sdate , this will fetch the products sold on the given date , and total sold qty .

If some products are returned which are entered in rqty , then this should delete all the records of the product on that sdate , and these products as spread along several billno's .

View 19 Replies View Related

SQL & PL/SQL :: Delete Duplicate Records

Sep 29, 2010

say I have duplicate records in TABLE3, can I use following SQL to delete the duplicates?FYI, BUS_FID is unique number column.

TABLE3
------------------------
ori_id*************id***********r_f_a****r_t_a*******bus_id
72840000040572*****740040572****255******267*********1
72840000040572*****740040572****255******267*********2
2840000040572******20040572*****25*******27**********3
7840000040572******70040572*****2********6***********4

DELETE FROM TABLE3 WHERE BUS_ID NOT IN (SELECT MIN(BUS_ID) FROM TABLE3 GROUP BY ORI_ID);

consider TABLE3 has millions of millions of data, say 40 millions.Update, I have tried it and it is very slow...

View 5 Replies View Related

SQL & PL/SQL :: Delete Duplicate Records From A Table

Apr 13, 2011

I need to delete duplicate records from a table (indeed they are multiple duplicates).

Table Data

IDGroupQty
1KK30
1KK0
1KK19
2AA0
2AA30
3AA0
3AA30
3AA30
3AA9

My aim is to delete duplicates out of above data, with the below condtions.

1) first record with value 30 and then with value 0.
2) if there are 3 duplicate records ex: ID is 1 and Group KK, then i have to delete both 30 & 0 qty records.
3) If there are more than 3 duplicate records ex: ID is 3 and Group is AA, the i have to delete all the records with qty value either 30 or 0 and.

I have written a query like below.

SELECT id,
unit,
RANK ()
OVER (PARTITION BY id, unit
ORDER BY id, unit)
num
FROM temp;

with the above query, i am unable to mark this dynamic duplications.

View 10 Replies View Related

SQL & PL/SQL :: How To Delete Records Of Accidental Commit

Jul 16, 2010

while i'm inserting a records into the table tablespace has got full and next statement which is commit is executed

so now i need to remove the data due to the last insert into the table.

Table size is very huge and i was unable to find the records any criteria.

View 7 Replies View Related

SQL & PL/SQL :: Delete Duplicate Records From Table

Aug 30, 2010

How can i delete duplicate records from the table.

View 2 Replies View Related

SQL & PL/SQL :: How To Delete Records Found With MINUS

Dec 1, 2010

I wish to delete records found with function MINUS from file1, which is a result of records not found in file2.

Both codes are taken way too long.

ps. none of the columms are unique, and some records have no value in some columns

DELETE
FROM file1 y
WHERE EXIST (SELECT *
FROM (
SELECT a.col1, a.col2, a.col3, a.col4
FROM file1 a

[Code]....

View 38 Replies View Related

Delete Records From Multiple Tables

Jun 27, 2011

I have a service that executes a pl/sql function (legacy app) to delete records from multiple tables. This function works fine in development, and has worked fine in production until about a week ago. I'm not a DB guy but the DB guys are trying to say this is an application issue. That may be, be the "insuff privileges" really leads me to believe otherwise.

What is causing this type of Oracle error? Permissions between dev and prod are the same, yet it works in dev but not prod.

ORA-29876: failed in the execution of the ODCIINDEXDELETE routine
ORA-20000: Oracle Text error:
DRG-50857: oracle error in textindexmethods.ODCIIndexDelete
ORA-20000: Oracle Text error:
DRG-10602: failed to queue DML change to column ABSTRACT for primary key AAAfBoAAEAABa62AAA
DRG-50857: oracle error in drexrdml
ORA-01031: insufficient privileges
[code]....

View 2 Replies View Related

Performance Tuning :: Delete No Of Records From A Table

Aug 3, 2010

I am using one script to delete the records from a table, its taking 1hr to delete.

declare
cursor c1 is select ownerid,ownertype from nightly_metric_projects
;
v1 c1%rowtype;
open c1;
loop
fetch c1 into v1;
exit when c1%notfound;
DELETE FROM DGT_ITEMEFFORTDATA WHERE OWNERTYPE = c1.OWNERTYPE
AND OWNERID = c1.OWNERID;
end loop;
close c1;
commit;

nightly_metric_projects--1200 records
DGT_ITEMEFFORTDATA--13200000

View 14 Replies View Related

SQL & PL/SQL :: Delete Duplicate Records Without Rowid And Drop

Apr 7, 2012

I want to delete the duplicate records from a table without using Below 2 methods:

1> delete from table_1 a where row_id not in (select min(row_id) from Table_1 b where a.PK=b.PK);

2> Insert into Table_2 select distinct * from Table_1;
Drop table Table_1;
Rename Table_2 to Table_1;

View 20 Replies View Related

SQL & PL/SQL :: Delete Duplicate Records Using Analytical Function

Dec 22, 2012

how to delete duplicated records from a table without using row_id. I found the duplicated rows from a table using Analytical Function. But i could not use the Analytical function in the where condition.

My table(tab2) Structure is

DEPTNODEPT_NAMEEMPIDSEXID1
107jadf 1F1
40asdf 55
10purchase 2M2
10sales 3M3
30HR 4F4

I found the Duplicate Record by using the query

with a as
(select deptno,dept_name,empid,sex,id1,row_number()over(partition by deptno order by deptno) rnum from tab2)
select * from a where rnum >1

how to delete duplicate record .

View 19 Replies View Related

PL/SQL :: How To Delete Records Checking Data And Time

Oct 28, 2013

I want to delete the records which are less than or equal to this date 

MIN(TRUNC(sale_week_date)-(1/(24*60*60)))  

For that I have created the following procedure.

 CREATE OR REPLACE PROCEDURE DELETE_DATA_WEEKISMIN_DATE DATE;SELECT MIN(TRUNC(sale_week_date)-(1/(24*60*60))) INTO MIN_DATE
FROM sales_week; DBMS_OUTPUT.PUT_LINE(MIN_DATE); 
DELETE FROM sales WHERE sale_date <= MIN_DATEAND sales_creation_date <= MIN_DATEAND sales_update_date <= MIN_DATE; END;

 If declare as MIN_DATE Date;

it's not taking time. If declare as MIN_DATE Timestamp; It is taking milli seconds also. 18-OCT-13 11.59.59.000000 PM SALE_DATE ,SALES_CREATION_DATE and SALES_UPDATE_DATE in this  format  18-OCT-2013 11.59.59 AM. How  to delete the records which are less than or equal to this date  MIN(TRUNC(sale_week_date)-(1/(24*60*60))) ..

View 9 Replies View Related

SQL & PL/SQL :: Delete Statement Is Deleting 1200000 Records

Sep 7, 2010

I executed the following delete statement.

DELETE FROM sre_t WHERE TO_CHAR(end_dt,'yyyy')<'2000'
or TO_CHAR(start_dt)<'yyyy')<'2000';

It's executing for 15 to 20 minutes after that i got the error "session timed out"..The table is having four crore records.The delete statement is deleting 12,00000 records.

View 4 Replies View Related

Replication :: Alternative For Complete Refresh / Delete Records From MVIEWS?

Aug 19, 2009

TABLE NAME :ABC
(PARTITION BASE TABLE - 84 Partition and each Partition has 500-800 Millions of Records)

/* Step1 Create MATERIALIZED VIEW LOG */
CREATE MATERIALIZED VIEW LOG ON ABC;

/* Step2 Create MATERIALIZED VIEW Refresh after Every 20 Minutes */
CREATE MATERIALIZED VIEW MV_ABC
REFRESH FAST
START WITH SYSDATE
NEXT SYSDATE+20/ (24*60) AS
SELECT * FROM ABC
WHERE TMSTP > SYSDATE-1;

Scenario:Intially data extracted will be "Greater than SYSDATE-1 = 18/08/2009 11:27:39 " - 76 Millions of Records After 20 Min of FAST Refresh, it will add 2500 Records

i)Is query in the MVIEWS (MV_ABC) SYSDATE-1 will be changed on each FAST Refresh, as observation (as per definition) it is incrementing the records to intial extracted data?

ii)As COMPLETE Refresh will be expensive to execute on the partition base table on each refresh.
Is there any alternative way to achieve the Nature of COMPLETE REFRESH in Materialized View?

iii)Is Delete or Conditional Delete option is possible in Materialized View (i.e not a delete from the base table but the delete from MVIEWS)?

iv)What is the machnism for populating the logs for MVIEWS?Is it overhead for the system and better than a Trigger based approach?

View 11 Replies View Related

SQL & PL/SQL :: Delete Bulk Records In Tables From Which Path Can See How Much Space Is Free

May 5, 2010

Im a oracle pl/sql developer but I didnt learn oracle as a language. With my sql skills I started working on Oracle.In my project every table has an associated MLOG$ table for it.

For eg.

CREATE TABLE MLOG$_TEST
(
ID VARCHAR2(64 BYTE),
SNAPTIME$$ DATE,
DMLTYPE$$ VARCHAR2(1 BYTE),
OLD_NEW$$ VARCHAR2(1 BYTE),
CHANGE_VECTOR$$ RAW(255)
)

So is MLOG$_TEST oracle's internal table.

Whenever an insert/update/delete happens it is recorded in MLOG$ tables as I/U/D for the priamry key.So if I do a bulk delete of records in tables an entry is made into MLOG$ tables. So deleting old records in a database doesn't free much space.If this is oracle internal table is it advisable to delete from MLOG$ tables too.

My oracle database is mounted on the Linux server.If I delete bulk records in tables from which path I can see how much space is freed.

View 9 Replies View Related

SQL & PL/SQL :: Write Query To Delete Similar Records In Particular Fields (columns) In Different Tables

Jul 17, 2012

write a query to delete similar records in particular fields(columns) in different tables.

View 2 Replies View Related

How To Delete SID Name (oracle) From Computer

Oct 29, 2010

How to delete SID name (oracle) from my computer ?

View 7 Replies View Related

SQL & PL/SQL :: Delete OS File In Oracle 8i

May 13, 2010

I am facing a problem while trying to delete an OS file using PL/SQL in Oracle8i v8.1.7.I have tried to use UTL_FILE.fremove but it is not supported in Oracle8i.

how can I delete a file Test.txt from C:Test location?

View 1 Replies View Related

Delete / Update From XL Sheet To Oracle?

May 7, 2008

have one XL sheet Doc that has 2 tabs. One has the list of keywords for deleting the records from Oracle that has the keywords in it. The second one needs the update query. Read the first column in the XL sheet and replace it with the second column value for the records that has the first column value in it.

I never worked in the combination of XL and Oracle.

View 3 Replies View Related

Oracle 10g - Delete 1000 Table?

Dec 21, 2007

I have 1000+ tables in a DISCOVER tablespace in 10g.

I need to drop ALL tables in this area and leave the tblsp intact so that I can IMP a data update from 9i (prod) into 10g (test).

Is there an easy cmd to drop all the tbls, or am I missing someway to do this in DB Console for 10g.

View 3 Replies View Related

SQL & PL/SQL :: Delete Redundant Table In Oracle?

Apr 23, 2012

Is there a SQL query to find out the redundant or unused table in Oracle.

Some tables shows no dependencies to itself or other schemas,but has got valid data in it, deleting it will affect the functionality of the system.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved