Hello i have got 4 tables
first table is menu have got column:
- Id number PK
- parent_id number FK to menu.Id
- title character varying(250)
- softdel boolean default false
second table is page:
- id as PK
- menu_id as FK to menu.id
- page_id as FK to page.id
- softdel boolean default false
third table is article:
- id as PK and FK to page.id
- softdel boolean default set to false
and fourth table article_lang:
- partial_id as PK
- id as FK to article.id
- language character
- softdel boolean default set to false
and i need to create update statement when i 'delete' (I mean set softdel true) menu with id for example 200 i also set softdel = false to all menus which parent_id = 200 and also all pages which menu_id = menus_id and articles which page_id = pages.id and so on....
i need only 1 update statement its possible to do it ??
it would be wonderful if i can create JPA query or EJB query :)
in oracle i write statement :
update pub_menu pm set softdel = 0 where pm.id in (
with menu_tree(id, parent_id) as (
select
t1.id , t1.parent_id
from menu t1
where t1.id = 454
union all
select
t2.id , t2.parent_id
from menu_tree
join menu t2 on menu_tree.id = t2.parent_id
)
select id from menu_tree
)
update menu_page pmp set softdel = 1 where pmp.menu_id in (
with menu_tree(id, parent_id) as (
select
t1.id , t1.parent_id
from menu t1
where t1.id = 454
union all
select
t2.id , t2.parent_id
from menu_tree
join menu t2 on menu_tree.id = t2.parent_id
)
select id from menu_tree
)
its working but i thing that is incorrect to do it like that :/
RETURNING some_id
to the first three updates, and using that value in the next update. Without a ddl, I won't elaborate. – Acceptedsoftdel
with triggers. – Bloodred