Skip to content

Instantly share code, notes, and snippets.

@ryancutter
Created January 2, 2016 20:56
Show Gist options
  • Select an option

  • Save ryancutter/2d2a0887b8ce230690f1 to your computer and use it in GitHub Desktop.

Select an option

Save ryancutter/2d2a0887b8ce230690f1 to your computer and use it in GitHub Desktop.
<named-native-query name="ObjectType.updateLocation">
<query>
<![CDATA[
update object_type set location = :location where id in (
with recursive tree (child) as (
values(:parent_id)
union
select ot.id from object_type ot, tree where ot.parent_id = child and ot.direct_location = false)
select child from tree)
]]>
</query>
</named-native-query>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment