postgresql7.2
select portal__delete(:portal_id);
update portal_elements
set region = :region,
page_id = :page_id,
sort_key = (select coalesce((select max(sort_key) + 1
from portal_elements
where page_id = :page_id
and region = :region),
1)
from dual)
where element_id = :element_id