Solved

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

Posted on 2011-03-09
6
742 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
Technology Partners: 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!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

751 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