Solved

PL-SQL Delete statement

Posted on 2011-02-23
4
282 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 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pivot rows to columns 1 34
Oracle DB Slows After Datapump Until Next Reboot 27 91
Optimize the query 5 43
Looping through datagridview and dataset ? 6 24
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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 information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

840 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