llmclaughlin
Programmer
I've tried to use the external table, it works, but not for what I am doing. The trouble with the below code is if there is only one record in the file it will exit on the last string in the file, meaning it will not get the kit type.
Any help.
text file
T61235,65499157588932185233756,SINGLE KIT ' will get all this line
T61239,6549915758893218523311,SINGLE KIT ' will get barcode but not the kit and exit loop.
l_bfile := BFILENAME ('RECEIVED_FILES', inFILENAME);
DBMS_LOB.fileopen (l_bfile);
l_size := DBMS_LOB.getlength (l_bfile);
LOOP
DBMS_APPLICATION_INFO.set_client_info (l_last || ' of ' || l_size);
l_current :=
DBMS_LOB.INSTR (l_bfile,
l_comma,
l_last,
1);
EXIT WHEN (NVL (l_current, 0) = 0);
l_rec.PLATE_NAME :=
UTL_RAW.cast_to_varchar2 (
DBMS_LOB.SUBSTR (l_bfile, l_current - l_last, l_last));
l_last := l_current + 1;
l_current :=
DBMS_LOB.INSTR (l_bfile,
l_comma,
l_last,
1);
EXIT WHEN (NVL (l_current, 0) = 0);
l_rec.FEDEX_BARCODE :=
UTL_RAW.cast_to_varchar2 (
DBMS_LOB.SUBSTR (l_bfile, l_current - l_last, l_last));
l_last := l_current + 1;
l_current :=
DBMS_LOB.INSTR (l_bfile,
l_newline,
l_last,
1);
EXIT WHEN (NVL (l_current, 0) = 0);
l_rec.KIT_TYPE :=
UTL_RAW.cast_to_varchar2 (
DBMS_LOB.SUBSTR (l_bfile, l_current - l_last, l_last));
l_last := l_current + 1;
INSERT INTO TEMP_PARSE_RECEIVING VALUES(l_rec.PLATE_NAME, l_rec.FEDEX_BARCODE, l_rec.KIT_TYPE);
END LOOP;
Louie
Any help.
text file
T61235,65499157588932185233756,SINGLE KIT ' will get all this line
T61239,6549915758893218523311,SINGLE KIT ' will get barcode but not the kit and exit loop.
l_bfile := BFILENAME ('RECEIVED_FILES', inFILENAME);
DBMS_LOB.fileopen (l_bfile);
l_size := DBMS_LOB.getlength (l_bfile);
LOOP
DBMS_APPLICATION_INFO.set_client_info (l_last || ' of ' || l_size);
l_current :=
DBMS_LOB.INSTR (l_bfile,
l_comma,
l_last,
1);
EXIT WHEN (NVL (l_current, 0) = 0);
l_rec.PLATE_NAME :=
UTL_RAW.cast_to_varchar2 (
DBMS_LOB.SUBSTR (l_bfile, l_current - l_last, l_last));
l_last := l_current + 1;
l_current :=
DBMS_LOB.INSTR (l_bfile,
l_comma,
l_last,
1);
EXIT WHEN (NVL (l_current, 0) = 0);
l_rec.FEDEX_BARCODE :=
UTL_RAW.cast_to_varchar2 (
DBMS_LOB.SUBSTR (l_bfile, l_current - l_last, l_last));
l_last := l_current + 1;
l_current :=
DBMS_LOB.INSTR (l_bfile,
l_newline,
l_last,
1);
EXIT WHEN (NVL (l_current, 0) = 0);
l_rec.KIT_TYPE :=
UTL_RAW.cast_to_varchar2 (
DBMS_LOB.SUBSTR (l_bfile, l_current - l_last, l_last));
l_last := l_current + 1;
INSERT INTO TEMP_PARSE_RECEIVING VALUES(l_rec.PLATE_NAME, l_rec.FEDEX_BARCODE, l_rec.KIT_TYPE);
END LOOP;
Louie