【发布时间】:2020-01-03 14:44:51
【问题描述】:
此代码正在运行
declare
tA table of rA; --where ra is a record
tB table of rB; --where rb is a record
A Ta;
B Tb;
begin
A :=gettA(); -- where gettA return type is tA
B :=gettBFromtA(A); -- where gettB return type is tB and take an input of type tA
end;
但现在我处于这种情况:
我没有 gettBFromtA 而是 getrBFromRa,其中 getrBFromRa 返回类型为 rB 并接受 rA 类型的输入。我想从 A 那里得到 B。
与开始的代码中执行相同操作的解决方案是创建一个中间函数 Inter,例如
function Inter (arg1 in ra.field1%type, ….. argn in ra.fieldn%type ) return rb
is
a ra;
b rb
begin
ra.arg1 := arg1 ….. ra.argn := argn
return getrBFromRa(a);
end;
并将倒数第二行替换为
select Inter(t.arg1, … t.argn) bulk collect into B from table(A) t.
有更简单的方法吗?
除此之外,记录的定义可能会发生变化。而且我想避免多次写我记录的字段名称。
我正在寻找一种在 select 语句中直接使用 getrBFromrA 的方法。
【问题讨论】: