select *
from portal_pages
where page_id = :page_id
update portal_pages
set name = :name,
portal_id = :portal_id,
layout_id = :layout_id,
sort_key = :sort_key
where page_id = :page_id
select case when count(*) = 0 then 0 else 1 end
from portal_elements
where page_id = :page_id
and state != 'hidden'