码迷,mamicode.com
首页 > 数据库 > 详细

SQL Script for read information from a csv file in FTP Server

时间:2017-04-29 15:14:54      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:format   global   har   getattr   pre   ftp   use   exists   exception   

DECLARE
  w_file_path   VARCHAR2(4000) := ‘XXIF_INPUT‘; --all_directories.directory_name
  w_file_name   VARCHAR2(4000) := ‘lcytest001.csv‘; --The file name
  w_file_exists BOOLEAN;
  w_file_length NUMBER(10) DEFAULT 0;
  w_file_type   utl_file.file_type;
  w_line        VARCHAR2(4000) DEFAULT NULL;
  w_rec_count   NUMBER := 1;
  w_block_size  BINARY_INTEGER;
  --
  TYPE tbl_varchar2 IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
  rec_record tbl_varchar2;
BEGIN
  --
  fnd_global.apps_initialize(user_id      => 1110,
                             resp_id      => 50683,
                             resp_appl_id => 222);
  --
  utl_file.fgetattr(w_file_path,
                    w_file_name,
                    w_file_exists,
                    w_file_length,
                    w_block_size);
  IF NOT w_file_exists THEN
    dbms_output.put_line(‘The File is not exist!‘);
  END IF;
  --
  IF w_file_length = 0 THEN
    dbms_output.put_line(‘The File is empty!‘);
  END IF;
  --
  w_file_type := utl_file.fopen(location     => w_file_path,
                                filename     => w_file_name,
                                open_mode    => ‘r‘,
                                max_linesize => 32767);
  LOOP
    utl_file.get_line(w_file_type, w_line, 32767);
    dbms_output.put_line(‘Information is :‘ || w_line);
    rec_record(w_rec_count) := w_line;
    w_rec_count := w_rec_count + 1;
  END LOOP;
EXCEPTION
  WHEN no_data_found THEN
    utl_file.fclose(w_file_type);
END;

SQL Script for read information from a csv file in FTP Server

标签:format   global   har   getattr   pre   ftp   use   exists   exception   

原文地址:http://www.cnblogs.com/zhchoutai/p/6785174.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!