我正在使用PL / SQL过程将之前生成的一个表插入到另一个现有表中:
INSERT INTO REI_LABOUR_COST (DEALER_NUMBER, DEALER_STATUS, BILLING_PARTNER, BSI_GW, YEAR, QUANTITY_FRU, LABOUR_EUR, LABOUR_LOCAL, REQUESTED_RATE)
select c001 as DEALER_NUMBER
, c002 as DEALER_STATUS
, c003 as BILLING_PARTNER
, c004 as BSI_GW
, c005 as YEAR
, c006 as QUANTITY_FRU
, c007 as LABOUR_EUR
, c008 as LABOUR_LOCAL
, c009 as REQUESTED_RATE
from apex_collections col
where collection_name = 'COLLECTION' and seq_id != 1
order by seq_id;
但它不起作用。没有错误消息或程序失败的其他迹象,但它没有在最终表格中显示任何结果。
第一个问题,有什么迹象表明我做错了吗?
第二个问题,如果命令失败,我会在哪里看到错误消息?我可以在某个地方启用它吗?
答案 0 :(得分:0)
在插入数据库之前,必须为每个成员属性更新apex集合。
First Apex流程: On Submit and Computation
ps aux --sort=-%mem | awk 'NR<=10{print $0}'
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ubuntu 27463 3.9 33.8 1045284 343428 ? Sl 13:11 0:05 sidekiq 4.1.2 Quickmilk [1 of 1 busy]
ubuntu 27466 1.5 31.3 841340 317708 ? Sl 13:11 0:02 Passenger RubyApp: /var/www/dairylac/Quickmilk/current/public (staging)
ubuntu 27370 2.8 18.6 492812 189012 ? Sl 13:11 0:04 Passenger AppPreloader: /var/www/dairylac/Quickmilk/current
postgres 27476 0.2 4.0 192540 41344 ? Ss 13:11 0:00 postgres: enbake quickmilk_dev_one 127.0.0.1(33998) idle
postgres 27915 21.0 3.5 189828 36296 ? Ss 13:13 0:03 postgres: enbake quickmilk_dev_one 127.0.0.1(34040) idle in transaction
postgres 1489 0.0 3.4 185752 34680 ? Ss Aug29 0:07 postgres: writer process
ubuntu 27444 0.0 1.5 42764 15228 ? Ssl 13:11 0:00 /var/www/dairylac/Quickmilk/shared/bundle/ruby/2.1.0/gems/appsignal-1.2.5/ext/appsignal-agent
root 1078 0.0 0.9 278696 10040 ? S<sl Aug29 0:01 /usr/lib/snapd/snapd
redis 1069 0.0 0.8 39236 8976 ? Ssl Aug29 0:42 /usr/local/bin/redis-server 127.0.0.1:6379
第二个Apex流程:提交后
declare
y pls_integer := 0;
v_msg varchar2(4000);
begin
if not apex_collection.collection_exists(p_collection_name=>'COLLECTION') then
wwv_flow.debug('No Apex collection found!');
else
for x in (select * from apex_collections where collection_name = 'COLLECTION' and seq_id != 1 order by seq_id)
loop
y := y+1;
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>1,p_attr_value=>wwv_flow.g_f01(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>2,p_attr_value=>wwv_flow.g_f02(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>3,p_attr_value=>wwv_flow.g_f03(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>4,p_attr_value=>wwv_flow.g_f04(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>5,p_attr_value=>wwv_flow.g_f05(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>6,p_attr_value=>wwv_flow.g_f06(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>7,p_attr_value=>wwv_flow.g_f07(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>8,p_attr_value=>wwv_flow.g_f08(y));
apex_collection.update_member_attribute (p_collection_name=> 'COLLECTION', p_seq=> x.seq_id,p_attr_number =>9,p_attr_value=>wwv_flow.g_f09(y));
end loop;
end if;
exception when others then
v_msg := ''||sqlerrm;
wwv_flow.debug('ERR: '||v_msg);
end;
答案 1 :(得分:-1)
我认为你不能像那样引用seq_id。
使用APEX_COLLECTION.DELETE_MEMBER
摆脱seq_id 1.
E.g。
BEGIN
APEX_COLLECTION.DELETE_MEMBER(
p_collection_name => 'COLLECTION',
p_seq => '1');
END;
然后继续正常。
编辑 - 它失败的原因是错误的数据类型错误。如果你检查调试器,你应该能看到这个。