ORACLE EBS输出文件

lerrormessage varchar2(1000);
out_file      utl_file.file_type;

out_file := utl_file.fopen('D_OUTPUT',
                               'FINISH_' || to_char(sysdate, 'yyyymmdd') ||
                               '.txt',
                               'W');
    utl_file.put_line(out_file,
                      '物料PartNo|组织|描述|单重G|单位|成本|类型|非保税发料|保税发料');
    FOR v_t IN c_t LOOP
      utl_file.put_line(out_file,
                        v_t.PartNo || ' | ' || v_t.org_id || ' | ' ||
                        v_t.description || ' | ' || v_t.weight_unit ||
                        ' | ' || v_t.PRIMARY_UNIT || '|' || v_t.Unit_Cost || '|' ||
                        v_t.ITEM_TYPE || '|' ||v_t.IN_issue|| '|' ||v_t.OUT_issue);
    END LOOP;
    utl_file.fclose(out_file);




模板:
PROCEDURE Main IS
    lerrormessage varchar2(1000);
    out_file      utl_file.file_type;
    CURSOR c_t IS
      SELECT 'a' a, 'b' b, 'c' c FROM dual;
  BEGIN
    out_file := utl_file.fopen('D_OUTPUT', 'a.txt', 'W');
    FOR v_t IN c_t LOOP
      utl_file.put_line(out_file, 'a|b|c');
      utl_file.put_line(out_file,
                        v_t.a || ' | ' || v_t.b || ' | ' || v_t.c);
      utl_file.fclose(out_file);
    END LOOP;
  EXCEPTION
    WHEN OTHERS THEN
      lerrormessage := SQLERRM;
  END Main;

猜你喜欢

转载自cqh520llr.iteye.com/blog/1980245