Solved

PL-SQL Delete statement

Posted on 2011-02-23
4
270 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
4 Comments
 
LVL 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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‚Ķ
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now