utl_file.sql

来自「Oracle 9i PL/SQL程序设计的随书源码」· SQL 代码 · 共 24 行

SQL
24
字号
REM UTL_FILE.sql
REM Chapter 12, Oracle9i PL/SQL Programming by Scott Urman
REM This block demonstrates the use of the UTL_FILE package. 

DECLARE
  v_FileHandle UTL_FILE.FILE_TYPE;
BEGIN
  -- Open the file /tmp/utl_file.txt for writing.  If the
  -- file does not exist, this will create it.  If the file
  -- does exist, this will overwrite it.
  v_FileHandle := UTL_FILE.FOPEN('/tmp/', 'utl_file.txt', 'w');
  
  -- Write some lines to the file.
  UTL_FILE.PUT_LINE(v_FileHandle, 'This is line 1!');
  FOR v_Counter IN 2..11 LOOP
    UTL_FILE.PUTF(v_FileHandle, 'This is line %s!\n', v_Counter);
  END LOOP;
  
  -- And close the file.
  UTL_FILE.FCLOSE(v_FileHandle);
END;
/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?