我的任务是将一个新的插入transaction_code
到一个包含同一个表的 min_cost 和 max_cost 的表中。我要做的是从事务代码为 2 的县获取 min_cost,从事务代码为 4 的县获取 max_cost。这是我到目前为止的情况。
我将收到的错误作为注释写在我收到它们的行旁边。我也尝试将数组用作表格,我认为它不会起作用,但我把它们留在了那里,这样你就会明白我的尝试(它们被注释掉了)。
declare
type cost_min_array IS TABLE OF court_cost.cost_range_min%type INDEX BY BINARY_INTEGER;
type cost_max_array IS TABLE OF court_cost.cost_range_max%type INDEX BY BINARY_INTEGER;
v_min_cost cost_min_array;
v_min_cost cost_max_array;
BEGIN
begin
select cost_range_min -- SQL STATEMENT IGNORED
bulk collect into v_min_cost
from court_cost
where state = 'IL'
and transaction_code = 4
and end_date is null
order by county
EXCEPTION WHEN OTHERS THEN --SQL COMMAND NOT PROPERLY ENDED
v_min_cost.delete;
END;
BEGIN
select cost_range_max -- SQL STATEMENT IGNORED
bulk collect into v_max_cost
from court_cost
where state = 'IL'
and transaction_code = 2
and end_date is null
order by county
EXCEPTION WHEN OTHERS THEN -- SQL COMMAND NOT PROPERLY ENDED
v_max_cost.delete;
END;
for indx in 1..v_min_cost.count
loop
insert into court_cost -- SQL STATEMENT IGNORED
(TRANSACTION_CODE,
STATE,
COUNTY,
COST_RANGE_MIN,
BEGIN_DATE,
END_DATE,
DATE_INSERTED,
COURT,
COST_RANGE_MAX)
select lcc.TRANSACTION_CODE,
lcc.STATE,
lcc.COUNTY,
v_min_cost(indx),
lcc.BEGIN_DATE,
lcc.END_DATE,
lcc.DATE_INSERTED,
lcc.COURT,
v_max_cost(indx)
from court_cost lcc
-- cost_min_array cmn,
-- cost_max_array cmx
end loop; -- SQL COMMAND NOT PROPERLY ENDED
end; -- ENCOUNTERED THE SYMBOL ; WHEN EXPECTING LOOP
任何朝着正确方向的推动将不胜感激,谢谢。