sql >> Database teknologi >  >> RDS >> Oracle

Postgresql og Oracle:Opdater flere tabeller fra almindelig underforespørgsel

Noget som:

with recursive menu_tree (id, parent_id) as (
   select id, parent_id
   from menu
   where id = 200
   union all 
   select c.id, c.parent_id
   from menu c
     join menu_tree p on p.id = c.parent_id
)
, deleted_menus (menu_id) as (
   update menu
      set softdel = true
   where id in (select id from menu_tree)
   returning menu.id
),
deleted_pages (page_id) as (
   update page
      set softdel = true
   where menu_id in (select menu_id from deleted_menus)
   returning page.id
),
deleted_articles (article_id) as (
   update article
     set softdel = true
   where page_id in (select page_id from deleted_pages)
)
update article_lang
   set softdel = true
where id in (select article_id from deleted_articles);


  1. Finjustering af Oracle DG40DBC

  2. Hvordan man opretter en oracle sql script spool fil

  3. Escapende og-tegn i SQL-streng

  4. Proceduren forventer parameter, som ikke blev leveret