我使用的是Apex 4.2.4和Oracle 11g。我有一个邮件列表应用程序,我在其中维护多个邮件列表。给定的收件人可以属于一个或多个列表。我使用Apex Shuttle来维护列表。 所有邮件收件人的来源都在表中:mail_recipient。 mail_recipient中有四个重要字段:
还有另一个表存储给定邮件列表的选定收件人:mail_recipient_category:mail_recipient_category中的重要字段是:
页面上有两个显示的项目。类别下拉列表(P31_email_list)和班车(P31_email_list_assignments) P31_email_list_assignments的LOV是:
Select last_name || ', ' || first_name || ' -- ' || email_address, prim_key from mail_recipient
order by 1;
穿梭源的PL / SQL函数体是:
declare
emp_list apex_application_global.vc_arr2;
i number := 1;
begin
for r in (Select mr.last_name || ', ' || mr.first_name || ' -- ' || mr.email_address, mr.prim_key
From mail_recipient mr left outer join
mail_recipient_category mrc
On mr.prim_key = mrc.recipient_fkey
Where mrc.category = :P31_EMAIL_LIST)
loop
emp_list(i) := r.prim_key;
i := i + 1;
end loop;
return APEX_UTIL.TABLE_TO_STRING(emp_list, ':');
end;
还有一个页面进程来更新数据库表mail_recipient_category。在计算和验证之后,在提交时执行该过程。 开始
MERGE INTO MAIL_RECIPIENT_CATEGORY ss
USING (
Select
shuttle.column_value shuttle_st
, db.recipient_fkey db_st
from
table(string_to_coll(:P31_email_list_assignments)) shuttle
left outer join mail_recipient_category db
on shuttle.column_value = db.recipient_fkey
and db.category = :P31_email_list) t
on (ss.recipient_fkey = t.db_st
and ss.category = :P31_email_list
)
when matched
then
update
set
ss.merge_check = ss.merge_check
delete
where
t.shuttle_st is null and ss.category = :P31_email_list
-- t.shuttle_st is null
when not matched
then
insert
(recipient_fkey, category)
values
(t.shuttle_st, :P31_email_list);
end;
班车工作正常,从左到右装载并保存物品。我遇到的问题是从航天飞机的右侧到左侧取消选择物品。将邮件收件人从右侧移到左侧后,当我按下提交按钮时,项目不会离开航班的右侧,并且该过程不会从mail_recipient_category表中删除该行。
感谢您的帮助。
答案 0 :(得分:2)
在与经验丰富的同事合作之后,我们确定页面流程有问题。具体来说,Merge语句的Delete子句似乎不适用于此穿梭机。我们最终在页面进程中的Merge语句之后添加了一个单独的Delete语句 我还删除了mail_recipient_category表,现在使用更有意义的名称mail_recipient_list。 穿梭栏名称为(p31_email_list_assignments)。
工作班车LOV定义代码是:
Select last_name || ', ' || first_name || ' -- ' || email_address, prim_key
From mail_recipient
order by 1;
工作班车源代码是:
declare
mail_list apex_application_global.vc_arr2;
i number := 1;
begin
for r in (Select mr.last_name || ', ' || mr.first_name || ' -- ' || mr.email_address, mr.prim_key
From mail_recipient mr left join
mail_recipient_list mrl
On mr.prim_key = mrl.recipient_fkey
Where mrl.list = :P31_EMAIL_LIST)
loop
mail_list(i) := r.prim_key;
i := i + 1;
end loop;
return APEX_UTIL.TABLE_TO_STRING(mail_list, ':');
end;
工作提交后页面流程代码为:
Begin
Merge Into MAIL_RECIPIENT_LIST mrl
Using (
Select
shuttle.column_value shuttle_cv
, db.recipient_fkey db_rfk
From
table(string_to_coll(:P31_email_list_assignments)) shuttle
left outer join mail_recipient_list db
on shuttle.column_value = db.recipient_fkey
and db.list = :P31_email_list) t
On (mrl.recipient_fkey = t.db_rfk
And mrl.list = :p31_email_list
)
When Matched
Then
Update
Set
mrl.merge_check = mrl.merge_check
-- Delete
-- Where
-- t.shuttle_cv is null
When Not Matched
Then
Insert
(recipient_fkey, list)
Values
(t.shuttle_cv, :P31_email_list);
/* The commented-out delete clause of the Merge statement never worked with this shuttle.
The following delete statement will every time this page process is called
*/
Delete from MAIL_RECIPIENT_LIST
Where instr(':' || :P31_email_list_assignments || ':',':' || recipient_fkey || ':') = 0
And list = :P31_email_list;
end;
我希望有人觉得这很有用。