|
我在Metalink 里找到一些资料希望对你们有些帮助。
但要说明一点:这个包只能在Developer 2000 里使用。
在PL/SQL 里用:Utl_file ,语法跟TEXT_IO 一样。
总的说来,这两个包都有缺陷。它们会在文件的尾端加上一个
回车符。
Oracle PL/SQL Technical Forum
Displayed below are the messages of the selected thread.
Thread Status: Closed
From: Karen Kolbe 03-Apr-01 18:34
Subject: TEXT_IO
TEXT_IO
Was reading in the Oracle PL/SQL Programming on File I/O.
The book talks about Text_IO as a client-sid PL/SQL package similar to UTL_FILE.
So, I have a simple procedure which outputs a file using UTL_FILE. And tried to simply changed all the references to UTL_FILE to TEXT_IO. Then, attempted to create this procedure via sql/plus.
The procedure is failing to compile giving the following errors
PLS-00201: identifier 'TEXT_IO.FILE_TYPE' must be declared
PLS-00201: identifier 'TEXT_IO.IS_OPEN' must be declared
PLS-00320: the declaration of the type of this expression is
incomplete or malformed
PLS-00201: identifier 'TEXT_IO.INVALID_PATH' must be declared
Do you need to install another module to get text_io other than Oracle EE database?
Here's my attempt
set serveroutput on
create or replace procedure example_textio as
v_FileHandle TEXT_IO.FILE_TYPE;
v_name VARCHAR2(9);
v_banner VARCHAR2(64);
CURSOR my_cursor is
select name, banner
from v$database, v$version;
begin
IF TEXT_IO.IS_OPEN(v_FileHandle) THEN
TEXT_IO.FCLOSE(v_FileHandle);
END if;
v_FileHandle := TEXT_IO.FOPEN('example.log','w');
TEXT_IO.PUT_LINE(v_FileHandle, 'DB ' ||' ' || 'BANNER');
TEXT_IO.PUT_LINE(v_FileHandle, '____' ||' ' || '_____________________________________');
open my_cursor;
LOOP
FETCH my_cursor into v_name, v_banner;
EXIT WHEN my_cursor%NOTFOUND;
TEXT_IO.PUT_LINE(v_FileHandle, v_name ||' '|| v_banner);
END LOOP;
close my_cursor;
TEXT_IO.FCLOSE(v_FileHandle);
EXCEPTION
WHEN TEXT_IO.INVALID_PATH THEN
RAISE_APPLICATION_ERROR (-20100, 'Reset: Invalid Path');
WHEN TEXT_IO.INVALID_MODE THEN
RAISE_APPLICATION_ERROR (-20101, 'Reset: Invalid Mode');
WHEN TEXT_IO.INVALID_OPERATION THEN
RAISE_APPLICATION_ERROR (-20102, 'Reset: Invalid Operation');
WHEN TEXT_IO.WRITE_ERROR THEN
RAISE_APPLICATION_ERROR (-20103, 'Reset: Write Error');
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20104, 'Reset: Other');
END example_textio;
/
--------------------------------------------------------------------------------
From: Oracle, krishna kumar sivasubramanian 04-Apr-01 04:31
Subject: Re : TEXT_IO
Hello
TEXT_IO is a forms built_in packagge. You can not use it in server side pl/sql.You have to utl_file to read/write to file.
Regards
S.Krishna Kumar
|