如何在PLSQL中将一个阵列1复制到另一个阵列2中?
假设一个小数组有10行,另一个大数组有50行,我想用小数组中的10行替换第二个数组中的第10个第一行:如何在PLSQL中将一个阵列1复制到另一个阵列2中?,plsql,Plsql,假设一个小数组有10行,另一个大数组有50行,我想用小数组中的10行替换第二个数组中的第10个第一行: declare nb_inactif_gcp number; nb_prem_gcp number; type tab_pot is record( NUMR_DOSS_ECNM number, ptf number, SEG_BANCO_2020_RELT varchar(9 B
declare
nb_inactif_gcp number;
nb_prem_gcp number;
type tab_pot is record(
NUMR_DOSS_ECNM number,
ptf number,
SEG_BANCO_2020_RELT varchar(9 BYTE),
SF number );
type tab is table of tab_pot index by binary_integer ;
tab_sup_pot tab ;
type inac is record(
NUMR_DOSS_ECNM number,
ptf number,
SEG_BANCO_2020_RELT varchar(9 BYTE),
SF number);
type tablo is table of inac index by binary_integer ;
tab_inac tablo ;
TYPE t_tab_emp IS VARRAY ;
tab_emp t_tab_emp;
begin
-------- initialisation and filling the table
for i in 1..nb_prem_gcp loop
tab_sup_pot(i).NUMR_DOSS_ECNM := i ;
tab_sup_pot(i).ptf := i;
tab_sup_pot(i).SEG_BANCO_2020_RELT := 'C';
tab_sup_pot(i).SF := i;
end loop;
for i in 1..nb_prem_gcp loop
select * into tab_sup_pot(i)
from (Select *
from
(Select *
from ptf_asup_sans_pro_prem_trie
where rownum<=i
order by rownum desc) b
where rownum=1);
end loop;
---initialisation and filling the table
for i in 1..nb_inactif_gcp loop
tab_inac(i).NUMR_DOSS_ECNM := i ;
tab_inac(i).ptf := i;
tab_inac(i).SEG_BANCO_2020_RELT := 'C';
tab_inac(i).SF := i;
end loop;
for i in 1..nb_inactif_gcp
loop
select * into tab_inac(i)
from (Select *
from (Select *
from ptf_gcp_inactif
where rownum<=i
order by rownum desc
) b where rownum=1);
end loop;
如果您能帮助我,我将不胜感激。您所说的“它不起作用”是什么意思?你有错误吗?你没有得到任何(或错误的)结果吗?首先,
tab_inac(i).ptf:=tab_sup_pot(i).ptf:=i代码>看起来不对;为什么:=i
在那里?还有类型t\u tab\u emp是VARRAY
不正确-您缺少varray和数据类型中的元素数量。你的varchar应该是VARCHAR2s。而nb\u prem\u gcp
在哪里声明?您不可能自己运行示例代码,因为它根本无法正常工作。请更新您的示例代码以更正语法错误。@Boneist我已使用I初始化数组。您可能已经这样做了,但在最后一个for循环的一行中有两个赋值。不对,你的程序有很多重复。为什么不先让一点代码正常工作,然后再进行扩展呢?
for i in 1..nb_inactif_gcp loop
tab_inac(i).NUMR_DOSS_ECNM := tab_sup_pot(i).NUMR_DOSS_ECNM ;
tab_inac(i).ptf := tab_sup_pot(i).ptf;
tab_inac(i).SEG_BANCO_2020_RELT := tab_sup_pot(i).SEG_BANCO_2020_RELT ;
tab_inac(i).SF := tab_sup_pot(i).SF ;
end loop
end ;