Solved

PL-SQL Delete statement

Posted on 2011-02-23
4
293 Views
Last Modified: 2012-08-14
Hi, I am trying to delete records from one table upon reletion to the other
somephing like this:

 
DELETE STATEMENTS A
FROM reverselines T
WHERE A.ACCNO = T.ACCNO AND A.FIYID= T.FIYID AND A.PERID = T.PERID AND A.LINENO = T.LINENO

Open in new window


I am new to PL-SQL and I need help on that.

Thank you for your help.



0
Comment
Question by:rkanabus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 34958806
this should do, presuming you want to delete from Statements table. otherwise, you just reverse the 2 table names
DELETE STATEMENTS A
WHERE EXISTS( SELECT NULL 
   FROM reverselines T
       WHERE A.ACCNO = T.ACCNO AND A.FIYID= T.FIYID AND A.PERID = T.PERID AND A.LINENO = T.LINENO
  )

Open in new window

0
 
LVL 19

Assisted Solution

by:elimesika
elimesika earned 250 total points
ID: 34958825
try this
DELETE FROM STATEMENTS A
WHERE EXISTS
  ( select  A.ACCNO
     from  reverselines T
     WHERE A.ACCNO = T.ACCNO AND 
           A.FIYID= T.FIYID AND
           A.PERID = T.PERID    AND 
           A.LINENO = T.LINENO );

Open in new window

0
 

Expert Comment

by:mnaeemsattar
ID: 34958850
You can't use table or view name before the 'From' clause in plsql.  so right statement should be like this:

 
DELETE 
FROM STATEMENTS A, REVERSELINES T
WHERE A.ACCNO = T.ACCNO AND A.FIYID= T.FIYID AND A.PERID = T.PERID AND A.LINENO = T.LINENO

Open in new window

0
 

Author Comment

by:rkanabus
ID: 34958856
Hi, thank you for your help, both solutions are correct.



0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question