update ttl_comments
set message = :message,
message_format = :message_format
where comment_id = :comment_id
insert into ttl_comments
(comment_id, ticket_id, creation_user, message, message_format)
values
(:comment_id, :ticket_id, :caller_id, :message, :message_format)
select p.email
from parties p, ttl_assignments ta
where ta.ticket_id = :ticket_id and
ta.user_id = p.party_id
UNION
select p.email
from ttl_v_tickets t, parties p
where t.ticket_id = :ticket_id and
t.creation_user = p.party_id
select ticket_id from ttl_comments where comment_id = :comment_id