oracle8.1.6
select mail_job_id
from ml_mail_jobs
where state = 'active'
and scheduled_date <= sysdate
update ml_mail_jobs
set state = 'started',
execution_date = sysdate
where mail_job_id = :mail_job_id
select r.mime_type, r.title, r.filename
from cr_revisions r
where r.revision_id = :css_revision_id
union
select r.mime_type, r.title, r.filename
from cr_items i, cr_revisions r
where r.item_id = i.item_id
and i.parent_id = :mail_job_id
update ml_user_email_log
set last_mail_date = sysdate
where user_id = :user_id
update ml_mail_jobs
set state = 'finished',
mails_sent = :mail_count,
track_links_p = (select case when count(*) = 0 then 'f' else 't' end
from mail_link_mail_map m
where mail_id = :mail_job_id)
where mail_job_id = :mail_job_id
insert into ml_bounce_log (mail_job_id, user_id, sending_time,
bouncing_time)
(select mail_job_id, user_id, send_date as sending_time,
sysdate as bouncing_time
from ml_email_log
where mail_job_id = :job_id
and user_id = :user_id)