[英]when button pressed trigger raised unhandled exception ora-01401
I am try to insert data from .CSV into Oracle db
Everything works fine, but after a couple of second I get error 我尝试将数据从.CSV插入Oracle db
一切正常,但是几秒钟后出现错误
when button pressed trigger raised unhandled exception ora-01401
I have around 1200 records
to insert, when I check in database I see that insert only around 630 record
. 我有大约1200 records
要插入,当我在数据库中检入时,我看到插入仅在630 record
附近。
declare
import_file text_io.file_type;
export_file text_io.file_type;
import_file_name varchar2(1000);
export_file_name varchar2(1000);
import_log_file text_io.file_type;
import_log_file_name varchar2(1000);
vec_importovano number;
brojac number;
brojac_redova number;
linebuf varchar2(5000);
p_rbr VARCHAR2(30);
p_polica VARCHAR2(30);
p_banka VARCHAR2(20);
p_kontakt VARCHAR2(30);
kraj_fajla number;
begin
brojac_redova:=0;
p_rbr:=100001;
import_file_name := :Global.Lokacija_prenosa||:import.naziv_fajla||:Global.Ekstenzija_prenosa;
import_file := text_io.fopen(import_file_name,'r');
delete from zivot_trajni_nalog_ponude where banka is not null;
commit;
kraj_fajla := 0;
while kraj_fajla = 0 loop
begin
brojac_redova:=brojac_redova+1;
p_rbr:=p_rbr+1;
text_io.get_line(import_file, linebuf);
if brojac_redova >= 2 then
p_polica:=substr(linebuf, 1, instr(linebuf,';',1,1)-1);
-- message(p_polica);
p_kontakt:=substr(linebuf, instr(linebuf,';',1,1)+1, instr(linebuf,';',1,2) - instr(linebuf,';',1,1)-1);
-- message(p_kontakt);
if instr(linebuf,';',1,3) > 0 then
p_banka := substr(linebuf,
instr(linebuf,';',1, 2) + 1,
instr(linebuf,';',1,3) - instr(linebuf,';',1,2)-1);
--message(p_banka);
else
p_banka := substr(linebuf,
instr(linebuf,';',1, 2) + 1);
--message(p_banka);
end if;
-- IF p_rbr is not null then
insert into ZIVOT_TRAJNI_NALOG_PONUDE
(BROJ_POLICE,REDNI_BROJ,BROJ_PONUDE,BANKA)
values(
p_polica,
p_rbr,
p_kontakt,
p_banka);
commit;
end if;
-- end if;
EXCEPTION WHEN NO_DATA_FOUND THEN kraj_fajla := 1;
end;
end loop;
if p_rbr is not null then
update zivot_trajni_nalog_ponude set redni_broj=rownum;
end if;
text_io.fclose(import_file);
message('Zavrseno prepisivanje fajla');
end;
What I did so far, I increase the buffer size and increase data in database but again same problem. 到目前为止,我做的是增加缓冲区大小并增加数据库中的数据,但同样是同样的问题。
Here is the data which cannot be inserted into database. 这是无法插入数据库的数据。 So It stop over here and It display error. 所以它停在这里并显示错误。
4555219;773017/1;S-PREMIUM BA
4555220;1862014551963592;ZIR
4555223;1861814551965445;ZIR
4555224;1861634551963417;ZIR
4555226;234011;PBS
4555230;1862614551947169;ZIR
4555231;1862814551965880;ZIR
4555237;234002/1;PBS
4555238;233817/1;PBS
4555239;233982;PBS
4555240;233422;PBS
4555242;233820;PBS
4555243;1861614551961478;ZIR
4555244;1861824551967142;ZIR
4555246;1861644551966181;ZIR
4555247;1861214551966542;ZIR
4555248;1861814551967773;ZIR
4555249;1862224521502138;ZIR
4555250;1861224551967075;ZIR
4555251;1862214551967462;ZIR
4555252;1863214551968285;ZIR
4555253;1863414551943831;ZIR
4555254;1863414551966238;ZIR
4555254;1863414551966238;ZIR
4555255;1863414551962746;ZIR
4555256;107160825;NLB
4555257;107161767;NLB
4555258;107158740;NLB
4555259;107162747;NLB
4555260;107162658;NLB
4555261;107157891;NLB
Try to empty linebuf
at the beginning of the loop 尝试在循环开始时清空linebuf
while kraj_fajla = 0
loop
begin
linebuf := null;
before every repetition for populating the value of that variable. 在每次重复之前填充该变量的值。
By the way local variable( p_banka
)'s length ( 20
) might be not enough for the returning values. 顺便说一下,局部变量( p_banka
)的长度( 20
)可能不足以返回值。 You may try to increase such as 150
. 您可以尝试增加例如150
。
@检查所有列的长度,此错误是在插入记录的字符串长度(来自csv文件)大于表列宽度时发生的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.