随笔 - 196  文章 - 0 评论 - 69 阅读 - 170万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

如下所示:

CREATE OR REPLACE PROCEDURE p_xlstooracle IS
   v_file                utl_file.file_type;
   out_v                 VARCHAR2(4000);
   v_id                  NUMBER;
   v_service_competition NUMBER;
   v_cu_market_share     NUMBER(6, 4);
   v_ct_market_share     NUMBER(6, 4);
   v_cm_market_share     NUMBER(6, 4);
   v_other_market_share  NUMBER(6, 4);
BEGIN
   IF utl_file.is_open(v_file) THEN
      utl_file.fclose(v_file);
   END IF;
   v_file := utl_file.fopen('UTL_FILE_DIR', 'i_exch_info2.xls', 'r');
   LOOP
      BEGIN
         utl_file.get_line(v_file, out_v);
      EXCEPTION
         WHEN no_data_found THEN
            EXIT;
      END;
      v_id   := substr(out_v, 1, instr(out_v, '    ', 1, 1) - 1);
      v_service_competition := substr(out_v,
                       instr(out_v, '    ', 1, 1) + 1,
                       instr(out_v, '    ', 1, 2) - instr(out_v, '    ', 1, 1)-1);
      v_cu_market_share := substr(out_v,
                       instr(out_v, '    ', 1, 2) + 1,
                       instr(out_v, '    ', 1, 3) - instr(out_v, '    ', 1, 2)-1);
      v_ct_market_share := substr(out_v,
                       instr(out_v, '    ', 1, 3) + 1,
                       instr(out_v, '    ', 1, 4) - instr(out_v, '    ', 1, 3)-1);
      v_cm_market_share := substr(out_v,
                       instr(out_v, '    ', 1, 4) + 1,
                       instr(out_v, '    ', 1, 5) - instr(out_v, '    ', 1, 4)-1);
      v_other_market_share := substr(out_v,
                       instr(out_v, '    ', 1, 5) + 1,
                       length(out_v) - instr(out_v, '    ', 1, 5));
      UPDATE i_exch_info
         SET service_competition = v_service_competition,
             cu_market_share     = v_cu_market_share,
             ct_market_share     = v_ct_market_share,
             cm_market_share     = v_cm_market_share,
             other_market_share  = v_other_market_share
       WHERE gwm_fid = v_id;
      dbms_output.put_line(out_v);
   END LOOP;
   utl_file.fclose(v_file);
END p_xlstooracle;
注:分隔符不是空格,我是直接拷贝的excel输出文本的那个间隔字符才行。

posted on   蓝紫  阅读(7110)  评论(1编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示