sql >> Databasteknik >  >> RDS >> Oracle

Postgresql och Oracle:uppdatera flera tabeller från vanlig underfråga

Något i stil med:

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. Bygg om index på InnoDB

  2. SQLite JSON_INSERT()

  3. Hur låses innodb-tabeller när ON INSERT-utlösaren bearbetas?

  4. MySql Last Insert ID, Connector .net