Solved

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

Posted on 2011-03-09
6
743 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
[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
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 6

Accepted Solution

by:
anumoses earned 500 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

Independent Software Vendors: 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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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.
Suggested Courses

623 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