dbTalk Databases Forums  

dynamic delete script based on columns

comp.databases.oracle.tools comp.databases.oracle.tools


Discuss dynamic delete script based on columns in the comp.databases.oracle.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ralphbuetikofer@yahoo.de
 
Posts: n/a

Default dynamic delete script based on columns - 11-20-2007 , 05:55 AM






hi all,

i got a big problem and hope, somebody can help. i have to create a
dynamic delete script which has to run once a day. the script should
find all tables containing a specific column (DEL_YN). then it should
physically delete all records in this tables with value 'Y' in that
column which indicates that the row has been 'deleted' by a user.

i know i can get a cursor with all table-names by the sys.all_objects
joining with the sys.all_tab_columns to determine if the specific
column exists in the table.
and i do know i can use this cursor to delete the records in all the
tables.

what i do not know is how can i assure that the delete script runs
through the tables in the right order (i.e. dependencies,
constraints......)??

can anybody help?

thanks in advance!

kind regards,
bueti

Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: dynamic delete script based on columns - 11-20-2007 , 08:05 AM






ralphbuetikofer (AT) yahoo (DOT) de wrote:
Quote:
hi all,

i got a big problem and hope, somebody can help. i have to create a
dynamic delete script which has to run once a day. the script should
find all tables containing a specific column (DEL_YN). then it should
physically delete all records in this tables with value 'Y' in that
column which indicates that the row has been 'deleted' by a user.

i know i can get a cursor with all table-names by the sys.all_objects
joining with the sys.all_tab_columns to determine if the specific
column exists in the table.
and i do know i can use this cursor to delete the records in all the
tables.

what i do not know is how can i assure that the delete script runs
through the tables in the right order (i.e. dependencies,
constraints......)??

can anybody help?

thanks in advance!

kind regards,
bueti
Tracking down dependencies is a lot of work made simple by building
your constraints correctly. Replace your current referential constraints
with deferrable constraints and the issue goes away.

For examples of deferrable referential constraints look here:
http://www.psoug.org/reference/constraints.html#cpr
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.