我有以下两个更新查询:
update nodes set path = 'A.S' ||
case
when nlevel(path) > nlevel('A.C') then subpath(path, nlevel('A.C'))
when nlevel(path) = nlevel('A.C') then ''
end
where path <@ 'A.C'
update nodes set id = 'A.S' where id = 'A.C'
如果我可以将这个多个更新合并成一个类似的方法,那就太完美了:
update nodes set path = 'A.S' ||
case
when nlevel(path) > nlevel('A.C') then subpath(path, nlevel('A.C'))
when nlevel(path) = nlevel('A.C') then ''
end
where path <@ 'A.C'
and
update nodes set id = 'A.S' where id = 'A.C'
我在寻找一种可能性,却找不到,
真的有可能吗?
如果能帮忙的话,谢谢
发布于 2018-01-31 05:29:22
小象:
update nodes
set path = 'A.S' ||
case
when path <@ 'A.C' and nlevel(path) > nlevel('A.C') then subpath(path, nlevel('A.C'))
when path <@ 'A.C' and nlevel(path) = nlevel('A.C') then ''
else
path
end
, id = case when id = 'A.C' then 'A.S' else id end
where path <@ 'A.C' or id = 'A.C'
在事务中尝试-我没有测试它!
https://stackoverflow.com/questions/48543255
复制相似问题