Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Deleting record on basis of master table ID

Christy H.Jan 17 2013 — edited Jan 17 2013
Hello,
SQL> desc news
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NEWS_ID                                   NOT NULL NUMBER(14)
 NEWS_DATE                                          TIMESTAMP(0)
 SL_ID                                              NUMBER(2)
 HEADING                                            VARCHAR2(3120)
 DESCRIPTION                                        VARCHAR2(3900)

SQL> desc news_location
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NEWS_ID                                            NUMBER(14)
 COUNTRY                                            VARCHAR2(32)
 REGION                                             NUMBER(2)

SQL> desc news_product
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NEWS_ID                                            NUMBER(14)
 PRODUCT_CATEGORY_ID                       NOT NULL NUMBER(14)
 PRODUCT                                            VARCHAR2(27)

SQL> desc news_service
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NEWS_ID                                            NUMBER(14)
 SERVICE_ID                                NOT NULL NUMBER(14)
 SRVIS                                              VARCHAR2(16)

SQL> desc news_info
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NEWS_ID                                            NUMBER(14)
 SOURCE                                             VARCHAR2(203)
 ORIGIONAL_NEWS                                     VARCHAR2(3900)
 HEADING                                            VARCHAR2(3110)

SQL> select count(*) from news where TO_CHAR(news_date,'YYYY') <  2012;

  COUNT(*)
----------
      8759
I am trying to delete news that are published before 2012 but detail tables consists child record on basis of news_id. Certainly simple delete query will not work

Please advise and thanks in anticipation
This post has been answered by Purvesh K on Jan 17 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 14 2013
Added on Jan 17 2013
16 comments
5,553 views