0

My delete statement returns a 933 error in Oracle, I'm not sure what is wrong-

DELETE b
from temp a
JOIN
  fact_tab b
on a.col1 = b.col1
and a.col2 = b.col2
and a.col3 = b.col3; 

Both tables dont have a primary key. select statement on the same thing works-

select * 
from temp a
JOIN
  fact_tab b
on a.col1 = b.col1
and a.col2 = b.col2
and a.col3 = b.col3; 
3

2 Answers 2

3

try this

DELETE FROM
  fact_tab
WHERE
  EXISTS
  (
    SELECT
      1
    FROM
      temp
    WHERE
      temp.col1 = fact_tab.col1 AND
      temp.col2 = fact_tab.col2 AND
      temp.col2 = fact_tab.col2
  )
Sign up to request clarification or add additional context in comments.

Comments

1

Oracle doesn't allow JOIN in a DELETE statement directly like that.

You could do the delete in the following way:

DELETE
FROM fact_tab
WHERE ROWID IN
  (SELECT b.rowid
  FROM temp a
  JOIN fact_tab b
  ON a.col1  = b.col1
  AND A.col2 = b.col2
  AND A.col3 = b.col3
  );

You could also use WHERE EXISTS clause.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.