Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I've learned more from your forums in 3 days than 3 months at school and on the job combined..."

Geography

Where in the world do Tek-Tips members come from?
eyetry (Programmer)
14 Aug 08 9:41
trying to figure out how to write a procedure that will write output to a file.  Ran this in sqlplus but it errors...

declare
    f utl_file.file_type;
    s varchar2(50) := 'this is a test record';
begin
    f := utl_file.fopen('EXAMPLEDATA','c:\example1.txt','W');
    utl_file.put_line(f,s);
    utl_file.fclose(f);
end;


What am I doing wrong?
 
Dagon (MIS)
14 Aug 08 10:54
You're probably making the common error of trying to create a file on your PC's C drive.   UTL_FILE doesn't work that way.  It writes to a file on the server where the database resides.
eyetry (Programmer)
14 Aug 08 11:13
in the example below is 'EXAMPLEDATA' then the target path on the DB server?  

declare
    f utl_file.file_type;
    s varchar2(50) := 'this is a test record';
begin
    f := utl_file.fopen('EXAMPLEDATA','example1.txt','W');
    utl_file.put_line(f,s);
    utl_file.fclose(f);
end;
Dagon (MIS)
14 Aug 08 11:28
That's correct.  You'll have to be able to log on to the DB server to look at it.
eyetry (Programmer)
14 Aug 08 16:01
resolved used

SELECT GET_UTL_FILE_DIR_FNC INTO L_UTL_FILE_DIR from dual;

declare
    f utl_file.file_type;
    s varchar2(50) := 'this is a test record';
begin
    f := utl_file.fopen(L_UTL_FILE_DIR,'example1.txt','W');
    utl_file.put_line(f,s);
    utl_file.fclose(f);
end;  
 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close