insert into wf_context_task_panels (workflow_key, transition_key, context_key, sort_key, header, template_url) select :workflow_key, :transition_key, :context_key, coalesce(max(sort_key)+1,1), :header, :template_url from wf_context_task_panels where workflow_key = :workflow_key and transition_key = :transition_key and context_key = :context_key