Friday 20 March 2015

UTL File Procedure

declare
  p_file_dir   varchar2(100) := 'MY_DIR';
  p_filename   varchar2(100) := 'abc.txt';
  v_filehandle utl_file.file_type;
  cursor emp Is
    select *
      from fci_customer_relation_api_tl r
     order by r.crm_account_number;
  v_dep_no fci.fci_customer_relation_api_tl%ROWTYPE;
begin
  v_filehandle := utl_file.fopen(p_file_dir, p_filename, 'w'); --Opening a file
 
  utl_file.putf(v_filehandle, 'SALARY REPORT :GENERATED ON %s\n', SYSDATE);
 
  utl_file.new_line(v_filehandle);
 
  for v_emp_rec IN emp LOOP
   -- v_dep_no := v_emp_rec.crm_account_number;
    utl_file.putf(v_filehandle,
                  '%s \n',
                  v_emp_rec.crm_activation_date||','||v_emp_rec.crm_account_number);
  end loop;
 
  utl_file.put_line(v_filehandle, '***END OF REPORT***');
 
  UTL_FILE.fclose(v_filehandle);
end;

No comments:

Post a Comment

Query to Find Receipt Class and its GL Combinition Query

SELECT ARC.NAME ReceiptClass,        ARC.CREATION_METHOD_CODE Creation_Mehthod,        DECODE (ARC.REMIT_METHOD_CODE,             ...