oracle 如何从 PL/SQL 写入文本文件,PLS 错误 00363
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23950850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to write to a text file from Pl/SQL, PLS error 00363
提问by Bato-Bair Tsyrenov
I am trying to write to a file from a procedure:
我正在尝试从过程写入文件:
out_File := Utl_File.FOpen('C:\test', 'batotest.txt' , 'W');
Utl_File.Put_Line(out_file , 'Hi this is text file!');
Utl_File.FClose(out_file);
Compilation errors for PACKAGE xxxxxxxx
PACKAGE xxxxxxxx 的编译错误
Error: PLS-00363: a?eà??íè? 'OUT_FILE' í? ì.á. è????ü??aàí? êàê à?e??àò íà?íà÷?íè?
Line: 795
Text: out_File := Utl_File.FOpen('C:\test', 'batotest.txt' , 'W');
Error: PL/SQL: Statement ignored
Line: 795
Text: out_File := Utl_File.FOpen('C:\test', 'batotest.txt' , 'W');
Error: PLS-00363: 'OUT_FILE' í? ì.á. è????ü??aàí? êàê à?e??àò íà?íà÷?íè?
Line: 797
Text: Utl_File.FClose(out_file);
Error: PL/SQL: Statement ignored
Line: 797
Text: Utl_File.FClose(out_file);
So this is my code and it gives me this error, what is wrong?
所以这是我的代码,它给了我这个错误,有什么问题?
回答by Bob Jarvis - Reinstate Monica
First, you need to create a directory object to access the C:\test directory:
首先,您需要创建一个目录对象来访问 C:\test 目录:
CREATE OR REPLACE DIRECTORY CTEST AS 'C:\test';
GRANT READ ON DIRECTORY CTEST TO PUBLIC;
Next, you need to use this directory object when opening your file:
接下来,您需要在打开文件时使用此目录对象:
DECLARE
out_File UTL_FILE.FILE_TYPE;
BEGIN
out_File := UTL_FILE.FOPEN('CTEST', 'batotest.txt' , 'W');
UTL_FILE.PUT_LINE(out_file , 'Hi this is text file!');
UTL_FILE.FCLOSE(out_file);
END;
Share and enjoy.
分享和享受。