select 1 from layout_pages where name = :name and pageset_id = :pageset_id and page_id <> :page_id select 1 from layout_pages where url_name = :url_name and pageset_id = :pageset_id and page_id <> :page_id insert into layout_pages (page_id, name, url_name, pageset_id, page_template, theme, sort_key) select :page_id, :name, :url_name, :pageset_id, :page_template, :theme, coalesce(max(sort_key) + 1, 0) from layout_pages where pageset_id = :pageset_id select page_id, sort_key from layout_pages where pageset_id = :pageset_id and sort_key > (select sort_key from layout_pages where page_id = :page_id) order by sort_key update layout_pages set sort_key = :sort_key - 1 where page_id = :update_page_id delete from layout_pages where page_id = :page_id insert into layout_pages (page_id, name, url_name, pageset_id, page_template, theme, sort_key) select :new_page_id, coalesce(:name, lp.name), coalesce(:url_name, lp.url_name), coalesce(:pageset_id, pageset_id), coalesce(:page_template, lp.page_template), coalesce(:theme, lp.theme), coalesce(:sort_key, sort_key) from layout_pages lp where lp.page_id = :page_id select element_id from layout_elements where page_id=:page_id order by element_id select * from layout_pages where page_id = :page_id update layout_pages set name = :name, url_name = :url_name, pageset_id = :pageset_id, page_template = :page_template, sort_key = :sort_key, theme = :theme where page_id = :page_id select case when count(*) = 0 then 0 else 1 end from layout_elements where page_id = :page_id and state != 'hidden' select page_id from layout_pages where pageset_id = :pageset_id and sort_key = :sort_key select page_id from layout_pages where pageset_id = :pageset_id and name = :page_name select 1 from dual where exists (select 1 from layout_elements where page_id = :page_id and state != 'hidden') select layout_page_templates.template from layout_page_templates where layout_page_templates.name = :page_template select le.element_id, le.page_column, le.sort_key from layout_elements le, layout_pages lp where lp.page_id = :page_id and le.page_id = lp.page_id and le.state != 'hidden' and exists (select 1 from acs_object_party_privilege_map where object_id = le.package_id and party_id = :user_id and privilege = le.required_privilege) order by le.page_column, le.sort_key