insert into workflow_cases ( case_id, workflow_id, object_id ) values ( :case_id, :workflow_id, :object_id ) insert into workflow_case_fsm ( case_id, current_state ) values ( :case_id, null ) select case_id from workflow_cases c, workflows w where c.object_id = :object_id and w.workflow_id = c.workflow_id and w.short_name = :workflow_short_name select distinct rpm.role_id from workflow_case_role_party_map rpm, party_approved_member_map pmm where rpm.case_id = :case_id and rpm.party_id = pmm.party_id and pmm.member_id = :user_id select a.action_id from workflow_cases c, workflow_actions a where c.case_id = :case_id and a.workflow_id = c.workflow_id and not exists (select 1 from workflow_initial_action wia where wia.workflow_id = c.workflow_id and wia.action_id = a.action_id) and (a.always_enabled_p = 't' or exists (select 1 from workflow_case_fsm cfsm, workflow_fsm_action_en_in_st waeis where cfsm.case_id = c.case_id and waeis.state_id = cfsm.current_state and waeis.action_id = a.action_id)) order by a.sort_order select count(*) from workflow_case_role_party_map where case_id = :case_id and role_id = :role_id select l.entry_id, l.case_id, l.action_id, a.short_name as action_short_name, a.pretty_name as action_pretty_name, a.pretty_past_tense as action_pretty_past_tense, l.user_id, u.first_names as user_first_names, u.last_name as user_last_name, u.email as user_email, l.action_date, to_char(l.action_date, 'fmMM/DDfm/YYYY') as action_date_pretty, l.comment, l.comment_format from workflow_case_log l, workflow_actions a, cc_users u where l.case_id = :case_id and a.action_id = l.action_id and u.user_id = l.user_id select impl.impl_name from workflow_role_callbacks r, acs_sc_impls impl, acs_sc_bindings bind, acs_sc_contracts ctr where r.role_id = :role_id and impl.impl_id = r.acs_sc_impl_id and impl.impl_id = bind.impl_id and bind.contract_id = ctr.contract_id and ctr.contract_name = :contract_name order by r.sort_order insert into workflow_case_role_party_map (case_id, role_id, party_id) values (:case_id, :role_id, :party_id) select count(*) from workflow_case_role_party_map where case_id = :case_id and role_id = :role_id and party_id = :party_id select current_state from workflow_case_fsm c where c.case_id = :case_id select c.case_id, c.workflow_id, c.object_id, s.state_id, s.short_name as state_short_name, s.pretty_name as pretty_state, s.hide_fields as state_hide_fields from workflow_cases c, workflow_case_fsm cfsm, workflow_fsm_states s where c.case_id = :case_id and cfsm.case_id = c.case_id and s.state_id = cfsm.current_state select c.case_id, c.workflow_id, c.object_id, s.state_id, s.short_name as state_short_name, s.pretty_name as pretty_state, s.hide_fields as state_hide_fields from workflow_cases c, workflow_case_fsm cfsm, workflow_fsm_states s, workflow_fsm_actions a where c.case_id = :case_id and cfsm.case_id = c.case_id and a.action_id = :action_id and ((a.new_state is null and s.state_id = cfsm.current_state) or (s.state_id = a.new_state)) select 1 from workflow_actions a where a.action_id = :action_id and (a.always_enabled_p = 't' or exists (select 1 from workflow_fsm_action_en_in_st waeis, workflow_case_fsm c_fsm where waeis.action_id = a.action_id and c_fsm.case_id = :case_id and waeis.state_id = c_fsm.current_state) ) update workflow_case_fsm set current_state = :new_state where case_id = :case_id insert into workflow_case_log (entry_id, case_id, action_id, user_id, comment, comment_format) values (:entry_id, :case_id, :action_id, :user_id, :comment, :comment_format) select count(*) from workflow_case_log where entry_id = :entry_id and case_id = :case_id and action_id = :action_id and user_id = :user_id and comment = :comment and comment_format = :comment_format