-2

This doesn't work in Oracle, please help

update mrp_indeksy mrp
inner join indeksy i
on i.indeks_czesci=mrp.indeks_czesci 
set mrp.jest_w_raporcie_pzm='N'
where i.id_grupy='WG' and mrp.kod_uzyskania='P' and i.nazwa_czesci NOT LIKE 'ZAWI%'
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Kamil
  • 7
  • This question has already been answered on Stack Overflow. Please check this question: http://stackoverflow.com/questions/2446764/oracle-update-statement-with-inner-join I suggest that you search on the site for related questions before posting. – Joseph B Jan 16 '15 at 16:29

1 Answers1

1

Generally in Oracle one uses WHERE EXISTS for update queries of this type:

UPDATE mrp_indeksy mrp
   SET mrp.jest_w_raporcie_pzm='N'
 WHERE mrp.kod_uzyskania='P'
   AND EXISTS ( SELECT 1 FROM indeksy i
                 WHERE i.indeks_czesci = mrp.indeks_czesci
                   AND i.id_grupy='WG'
                   AND i.nazwa_czesci NOT LIKE 'ZAWI%' )

You can read more about how to do an update of this kind at this page. Aside from the WHERE EXISTS method above, you can also do an "updatable view." However, you can't combine an update with a JOIN and UPDATE ... FROM is not valid Oracle syntax.

David Faber
  • 12,277
  • 2
  • 29
  • 40