Solved

how can I debug with Pl*Sql Developer when the procedure reads a file from Unix ?

Posted on 2011-03-24
7
534 Views
Last Modified: 2012-05-11
I develop in Pl*Sql, then run the procedures via Unix / Sql * Plus, the program reads flat files on Unix.

But how do I debug this, since the Pl*Sql Windows session doesn't recognize Unix ? Do I put the file on Windows ? If so, how do I read that ?

I read the Unix files like this:

fh_inp := UTL_FILE.FOPEN([UNIX FILE LOCATION],'fep_clm_clm_line_nwr76579.dat','R',2000);

UTL_FILE.GET_LINE (fh_inp, input_rec2);



0
Comment
Question by:Alaska Cowboy
  • 3
  • 3
7 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 35209504
you can't read remote files,  in this case your pc is "remote" to the db server.

you'll have to put your files on the unix server.

0
 
LVL 73

Accepted Solution

by:
sdstuber earned 75 total points
ID: 35209514
even when you are debugging from a windows client like pl/sql developer, toad or sql developer,  the pl/sql itself is still executing on the db so the unix file is local to the execution there
0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 35209574
sdstuber, ok, thanks.

are you saying I should be able to debug normally ? I always thought I couldn't debug from Pl*Sql Developer when reading a flat file from Unix.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 73

Expert Comment

by:sdstuber
ID: 35209585
shouldn't be a problem,  you can't "step into" the utl_file procedures themselves anyway,  so the location of those files is irrelevant.
0
 
LVL 2

Assisted Solution

by:choukssa
choukssa earned 50 total points
ID: 35209628

PL/SQL file operations are performed on server machine i.e. the machine where oracle is installed.

Consider the example below
CREATE OR REPLACE DIRECTORY MY_DIR AS '/uo1/my_data'
/

set serveroutput on
declare
    f utl_file.file_type;
    s varchar2(200);
begin
    f := utl_file.fopen('MY_DIR','sample2.txt','R');
    loop
        utl_file.get_line(f,s);
        dbms_output.put_line(s);
    end loop;
exception
    when NO_DATA_FOUND then
        utl_file.fclose(f);
end;

Open in new window

/

Though I am running the SQL block on the client machine.  The dIrectory MY_DIR has to be on the server machine.

You can find directories defined all_directories

--choukssa
0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 35209651
stdstuber and choukssa, ok, good, I guess I can do it. and I should have tried it first, but I just had it in mind that I can't do it. will give it a whirl, thanks.
0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 35210162
oops, guess I should have tried it first. but I had it locked in my brain it couldn't be done.

so it worked great !

Thanks.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now