oracle中如何使用utl_file写入文件 [英] How to write to files using utl_file in oracle

查看:40
本文介绍了oracle中如何使用utl_file写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 put 函数.我的程序不是用 put 编译的.但 putline 工作正常.我想在同一行打印

How to use put function.my procedure is not compiling with put. but putline is working fine. i want to print in the same line

推荐答案

以下是使用 UTL_FILE.PUT 和 UTL_FILE.PUT_LINE 调用的代码示例:

Here's an example of code which uses the UTL_FILE.PUT and UTL_FILE.PUT_LINE calls:

declare 
  fHandle  UTL_FILE.FILE_TYPE;
begin
  fHandle := UTL_FILE.FOPEN('my_directory', 'test_file', 'w');

  UTL_FILE.PUT(fHandle, 'This is the first line');
  UTL_FILE.PUT(fHandle, 'This is the second line');
  UTL_FILE.PUT_LINE(fHandle, 'This is the third line');

  UTL_FILE.FCLOSE(fHandle);
EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Exception: SQLCODE=' || SQLCODE || '  SQLERRM=' || SQLERRM);
    RAISE;
end;

输出如下:

This is the first lineThis is the second lineThis is the third line

分享和享受.

这篇关于oracle中如何使用utl_file写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆