Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do you use inner joins on a delete statement using oracle

Posted on 2011-03-09
6
Medium Priority
?
752 Views
Last Modified: 2012-05-11
Hello All,
I am getting this error when I try to compile the following sql statements in ORACLE. It is telling me that the statement is not ended correctly. It is highlighting the first inner join. Can someone tell me what is wrong here

DELETE FROM batch_payment_schedule bps
    INNER JOIN w_batch_pledge_entry wbpe ON wbpe.bpe_batch_number = bps.batch_number
    AND                                      wbpe.bpe_number       = bps.bpe_number
    INNER JOIN batch_pledge_entry bpe ON bpe.bpe_batch_number = wbpe.bpe_batch_number
    AND                                  wbpe.bpe_number      = bpe.bpe_number
    WHERE (wbpe.bpe_payment_frequency = 'O'
    AND bpe.bpe_payment_frequency <> 'O'
    AND bps.bpe_schedule_status = 'U'
    AND wbpe.xoption IN (adv_declarations.c_modify));
0
Comment
Question by:bill_home
6 Comments
 
LVL 6

Expert Comment

by:anumoses
ID: 35083390
DELETE FROM batch_payment_schedule bps
where .............
INNER JOIN w_batch_pledge_entry wbpe ON wbpe.bpe_batch_number = bps.batch_number

This has to be your sql
0
 
LVL 6

Expert Comment

by:anumoses
ID: 35083441
delete from batch_payment_schedule bps
where wbpe.xoption IN  (
select wbpe.xoption
from ......
inner join w_batch_pledge_entry wbpe ON wbpe.bpe_batch_number = bps.batch_number
...............
inner join batch_pledge_entry bpe ON bpe.bpe_batch_number = wbpe.bpe_batch_number
.........................
WHERE ...............
AND .................)
0
 

Author Comment

by:bill_home
ID: 35083568
Hello anumoses, you have two solutions...which one is it?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 6

Accepted Solution

by:
anumoses earned 2000 total points
ID: 35083584
try the second one.
0
 
LVL 2

Expert Comment

by:clayhopkins
ID: 35084588
Hi Bill-

Another option:

SELECT * FROM batch_payment_schedule bps
    INNER JOIN
      (w_batch_pledge_entry wbpe INNER JOIN batch_pledge_entry bpe
       ON bpe.bpe_batch_number = wbpe.bpe_batch_number
       AND bpe.bpe_number = wbpe.bpe_number)
    ON wbpe.bpe_batch_number = bps.batch_number
    AND wbpe.bpe_number = bpe.bpe_number
    WHERE (wbpe.bpe_payment_frequency = 'O'
    AND bpe.bpe_payment_frequency <> 'O'
    AND bps.bpe_schedule_status = 'U'
    AND wbpe.xoption IN (adv_declarations.c_modify));

I recommend running the SELECT * first to make sure it pulls back the stuff you want before deleting. :)  After you verify, you can just change SELECT * to DELETE and you're good to go.
0
 
LVL 11

Expert Comment

by:yuching
ID: 35125682
try this
Delete From batch_payment_schedule bps
Where Exists (
Select 1 From w_batch_pledge_entry wbpe 
 INNER JOIN batch_pledge_entry bpe ON bpe.bpe_batch_number = wbpe.bpe_batch_number
    AND wbpe.bpe_number = bpe.bpe_number
WHERE (wbpe.bpe_payment_frequency = 'O' 
    AND bpe.bpe_payment_frequency <> 'O'
    AND bps.bpe_schedule_status = 'U' AND wbpe.xoption IN (adv_declarations.c_modify)
	And wbpe.bpe_batch_number = bps.batch_number
    And wbpe.bpe_number = bps.bpe_number
	)

Open in new window

0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

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 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

916 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