555: c_max_linesize CONSTANT NUMBER := 4000;
556: c_commit_point CONSTANT NUMBER := 1000;
557: c_data_exchange_dir CONSTANT VARCHAR2 (30) := 'PER_DATA_EXCHANGE_DIR';
558: -- File Handling variables
559: l_file_type UTL_FILE.file_type;
560: l_filename VARCHAR2 (240);
561: l_location VARCHAR2 (4000);
562: l_line_read VARCHAR2 (4000) := NULL;
563: -- Batch Variables
595: END IF;
596:
597: -- Open flat file
598: l_file_type :=
599: UTL_FILE.fopen (l_location, l_filename, c_read_file, c_max_linesize);
600:
601: -- Loop over the file, reading in each line.
602: -- GET_LINE will raise NO_DATA_FOUND when it r4eaches EOF
603: -- so we use that as the exit condition for the loop
603: -- so we use that as the exit condition for the loop
604: <
605: LOOP
606: BEGIN
607: UTL_FILE.get_line (l_file_type, l_line_read);
608: l_batch_seq := l_batch_seq + 1;
609: hr_utility.set_location (' line read: ' || l_line_read, 60);
610: -- Calling the procedure tyo split the line into variables
611: split_line (p_line => l_line_read
739: END LOOP read_lines_in_file;
740:
741: -- Commit the outstanding records
742: COMMIT;
743: UTL_FILE.fclose (l_file_type);
744: hr_utility.set_location ('Leaving:' || l_proc, 260);
745: EXCEPTION
746: -- When file location is not proper
747: -- ***********************************************
748: WHEN e_fatal_error
749: -- No directory specified
750: THEN
751: -- Close the file in case of error
752: IF UTL_FILE.is_open (l_file_type)
753: THEN
754: UTL_FILE.fclose (l_file_type);
755: END IF;
756:
750: THEN
751: -- Close the file in case of error
752: IF UTL_FILE.is_open (l_file_type)
753: THEN
754: UTL_FILE.fclose (l_file_type);
755: END IF;
756:
757: hr_utility.set_location (l_proc, 270);
758: -- Set retcode to 2, indicating an ERROR to the ConcMgr
761: hr_utility.set_message (801, 'HR_SE_DATA_EXCHANGE_DIR_MIS');
762: -- Return the message to the ConcMgr (This msg will appear in the log file)
763: errbuf := hr_utility.GET_MESSAGE;
764: -- ***********************************************
765: WHEN UTL_FILE.invalid_operation
766: -- File could not be opened as requested, perhaps because of operating system permissions
767: -- Also raised when attempting a write operation on a file opened for read, or a read operation
768: -- on a file opened for write.
769: THEN
766: -- File could not be opened as requested, perhaps because of operating system permissions
767: -- Also raised when attempting a write operation on a file opened for read, or a read operation
768: -- on a file opened for write.
769: THEN
770: IF UTL_FILE.is_open (l_file_type)
771: THEN
772: UTL_FILE.fclose (l_file_type);
773: END IF;
774:
768: -- on a file opened for write.
769: THEN
770: IF UTL_FILE.is_open (l_file_type)
771: THEN
772: UTL_FILE.fclose (l_file_type);
773: END IF;
774:
775: hr_utility.set_location (l_proc, 280);
776: retcode := g_error;
780: || ' -> '
781: || l_filename
782: || ') - Invalid Operation.';
783: -- ***********************************************
784: WHEN UTL_FILE.internal_error
785: -- Unspecified internal error
786: THEN
787: IF UTL_FILE.is_open (l_file_type)
788: THEN
783: -- ***********************************************
784: WHEN UTL_FILE.internal_error
785: -- Unspecified internal error
786: THEN
787: IF UTL_FILE.is_open (l_file_type)
788: THEN
789: UTL_FILE.fclose (l_file_type);
790: END IF;
791:
785: -- Unspecified internal error
786: THEN
787: IF UTL_FILE.is_open (l_file_type)
788: THEN
789: UTL_FILE.fclose (l_file_type);
790: END IF;
791:
792: hr_utility.set_location (l_proc, 290);
793: retcode := g_error;
797: || ' -> '
798: || l_filename
799: || ') - Internal Error.';
800: -- ***********************************************
801: WHEN UTL_FILE.invalid_mode
802: -- Invalid string specified for file mode
803: THEN
804: IF UTL_FILE.is_open (l_file_type)
805: THEN
800: -- ***********************************************
801: WHEN UTL_FILE.invalid_mode
802: -- Invalid string specified for file mode
803: THEN
804: IF UTL_FILE.is_open (l_file_type)
805: THEN
806: UTL_FILE.fclose (l_file_type);
807: END IF;
808:
802: -- Invalid string specified for file mode
803: THEN
804: IF UTL_FILE.is_open (l_file_type)
805: THEN
806: UTL_FILE.fclose (l_file_type);
807: END IF;
808:
809: hr_utility.set_location (l_proc, 300);
810: retcode := g_error;
814: || ' -> '
815: || l_filename
816: || ') - Invalid Mode.';
817: -- ***********************************************
818: WHEN UTL_FILE.invalid_path
819: -- Directory or filename is invalid or not accessible
820: THEN
821: IF UTL_FILE.is_open (l_file_type)
822: THEN
817: -- ***********************************************
818: WHEN UTL_FILE.invalid_path
819: -- Directory or filename is invalid or not accessible
820: THEN
821: IF UTL_FILE.is_open (l_file_type)
822: THEN
823: UTL_FILE.fclose (l_file_type);
824: END IF;
825:
819: -- Directory or filename is invalid or not accessible
820: THEN
821: IF UTL_FILE.is_open (l_file_type)
822: THEN
823: UTL_FILE.fclose (l_file_type);
824: END IF;
825:
826: retcode := g_error;
827: errbuf :=
831: || l_filename
832: || ') - Invalid Path or Filename.';
833: hr_utility.set_location (l_proc, 310);
834: -- ***********************************************
835: WHEN UTL_FILE.invalid_filehandle
836: -- File type does not specify an open file
837: THEN
838: IF UTL_FILE.is_open (l_file_type)
839: THEN
834: -- ***********************************************
835: WHEN UTL_FILE.invalid_filehandle
836: -- File type does not specify an open file
837: THEN
838: IF UTL_FILE.is_open (l_file_type)
839: THEN
840: UTL_FILE.fclose (l_file_type);
841: END IF;
842:
836: -- File type does not specify an open file
837: THEN
838: IF UTL_FILE.is_open (l_file_type)
839: THEN
840: UTL_FILE.fclose (l_file_type);
841: END IF;
842:
843: hr_utility.set_location (l_proc, 320);
844: retcode := g_error;
847: || l_location
848: || ' -> '
849: || l_filename
850: || ') - Invalid File Type.';
851: WHEN UTL_FILE.read_error
852: -- ***********************************************
853:
854: -- Operating system error occurred during a read operation
855: THEN
852: -- ***********************************************
853:
854: -- Operating system error occurred during a read operation
855: THEN
856: IF UTL_FILE.is_open (l_file_type)
857: THEN
858: UTL_FILE.fclose (l_file_type);
859: END IF;
860:
854: -- Operating system error occurred during a read operation
855: THEN
856: IF UTL_FILE.is_open (l_file_type)
857: THEN
858: UTL_FILE.fclose (l_file_type);
859: END IF;
860:
861: hr_utility.set_location (l_proc, 330);
862: retcode := g_error;