dbTalk Databases Forums  

Re: Issues with writing to server-side log file.

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Re: Issues with writing to server-side log file. in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ddf
 
Posts: n/a

Default Re: Issues with writing to server-side log file. - 02-06-2009 , 03:34 PM






On Feb 6, 2:55*pm, seannakasone <snaka... (AT) flex (DOT) com> wrote:
Quote:
Hello, on the database server running Oracle 9.2, I want to write to a log
file. *I unsuccessfully tried the following:

DECLARE
* * * f UTL_FILE.FILE_TYPE;
BEGIN
* * * f := UTL_FILE.FOPEN('d:\temp', 'log.txt', 'w');
END;
/

It says, 'ORA-29280: invalid directory path' even if that folder exists
and the permissions allow everyone to write to it.

Someone told me to create a directory object so I can grant permissions to
it, as follows:

CREATE OR REPLACE DIRECTORY dirobj as 'd:\temp';
GRANT READ,WRITE ON DIRECTORY dirobj to snakason;
CONN snakason/mypass@hedev2
DECLARE
* * * f UTL_FILE.FILE_TYPE;
BEGIN
* * * f := UTL_FILE.FOPEN(dirobj, 'log.txt', 'r', 5000);
END;
/

But now I'm getting this error "PLS-00201: identifier 'DIROBJ' must be
declared". *I'm guessing dirobj is not in scope of the PL/SQL block, but
how to I remedy that? *If I put those lines within the PL/SQL block, I get
errors. *Sorry, I'm an Oracle newbie so I don't what works or does not
work in a PL/SQL block.
You need to submit your directory name in CAPS and in single quotes:

SQL> CREATE OR REPLACE DIRECTORY dirobj as 'c:\temp';

Directory created.

SQL> GRANT READ,WRITE ON DIRECTORY dirobj to bing;

Grant succeeded.

SQL> CONN bing/*&*&*&*&*&*&*&*&*&
Connected.
SQL> set serveroutput on size 1000000
SQL> DECLARE
2 f UTL_FILE.FILE_TYPE;
3 filebuf varchar2(4000);
4 BEGIN
5 f := UTL_FILE.FOPEN('DIROBJ', 'log.txt', 'R',
4000);
6 utl_file.get_line(f, filebuf);
7 dbms_output.put_line(filebuf);
8 utl_file.fclose(f);
9 END;
10 /
Yadda yadda yadda

PL/SQL procedure successfully completed.

SQL>


David Fitzjarrell


Reply With Quote
  #2  
Old   
seannakasone
 
Posts: n/a

Default Re: Issues with writing to server-side log file. - 02-06-2009 , 04:03 PM






Thanks it worked.

It needed to be in quotes and uppercase.

BTW, do you know how to show existing directory objects?


On Fri, 6 Feb 2009, seannakasone wrote:

Quote:
Hello, on the database server running Oracle 9.2, I want to write to a log
file. I unsuccessfully tried the following:

DECLARE
f UTL_FILE.FILE_TYPE;
BEGIN
f := UTL_FILE.FOPEN('d:\temp', 'log.txt', 'w');
END;
/

It says, 'ORA-29280: invalid directory path' even if that folder exists
and the permissions allow everyone to write to it.

Someone told me to create a directory object so I can grant permissions to
it, as follows:

CREATE OR REPLACE DIRECTORY dirobj as 'd:\temp';
GRANT READ,WRITE ON DIRECTORY dirobj to snakason;
CONN snakason/mypass@hedev2
DECLARE
f UTL_FILE.FILE_TYPE;
BEGIN
f := UTL_FILE.FOPEN(dirobj, 'log.txt', 'r', 5000);
END;
/

But now I'm getting this error "PLS-00201: identifier 'DIROBJ' must be
declared". I'm guessing dirobj is not in scope of the PL/SQL block, but
how to I remedy that? If I put those lines within the PL/SQL block, I get
errors. Sorry, I'm an Oracle newbie so I don't what works or does not
work in a PL/SQL block.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.