execute stored procedure to UTL_FILE FOPEN via db link

Posted on 2006-11-03
Last Modified: 2008-01-09
I login sqlplus on db_server_local on unix_local to run a remote stored procedure (via db link) on db_server_remote on unix_remote. The remote stored procedure uses UTL_FILE FOPEN.  Does the procedure open the file on unix_local or unix_remote?  Thanks.

Question by:ewang1205
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 17866471
Hi !

What is the syntax of the call to the remote procedure ?

LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 50 total points
ID: 17866498
i think it should be in unix_remote only. But i have never done it or tested it.


Author Comment

ID: 17866558
Any other expert opinion?  Thanks.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 48

Accepted Solution

schwertner earned 200 total points
ID: 17866565
Oracle controls the access to files the programmer does via the package UTL_FILE.
There are some prerequistes the DBA has to do before UTL_FILE can access files.

Server security for PL/SQL file I/O consists of a restriction on
the directories that can be accessed.
Accessible directories must be specified in the
instance parameter initialization file (INIT.ORA or SPFILE).

Specify the accessible directories for the UTL_FILE
functions in the initialization file
using the UTL_FILE_DIR parameter.
For example:
UTL_FILE_DIR = <directory name>

Starting from 9i you can use Oracle directories instead:

create or replace directory XMLDIR as 'E:\ICW_TASKS\XML\SOURCE\';
grant read on directory xmldir to my_user with grant option;

The remote stored procedure runs using the access rights assigned to the
owner of the procedure and this owner is remote.
So the remote procedure will see only the directory and files visible from the remote server.

The question if the local directory is visible from the remote server is an OS question.

Accessing Network Directories

Netware Networked Directories

For this to work ensure that the account that started the Oracle instance
has a mapped network drive connected using a fully qualified username/password
with the same drive letter and path as is specified by UTL_FILE_DIR.

NT Networked Directories

When an oracle instance is created the services that support it are setup
to "Log On As" the SYSTEM (or operating system) account, this account has
very few privileges and no access to NT Domains. To access another NT machine
the OracleServiceXXXX must be setup to logon to the appropriate NT Domain as
a user who has access to the required location for UTL_FILE.

To change the default logon for the Oracle services, go to :

  -> Control Panel
     -> Services
        -> OracleServiceXXXX (where XXXX is the instance name)
           -> Startup
              -> Log On As

Choose the "This Account" radio button, then complete the appropriate
domain login information. Repeat this procedure for the TNS Listener :

  -> Control Panel
     -> Services
        -> OracleXXXXTNSListener (where XXXX is the Oracle Home Name)
           -> Startup
              -> Log On As

If the listener is not configured to start as the same user as the Oracle
Service user will fail to connect with "ORA-12500 TNS:listener failed to start
a dedicated server process". Once the services have been setup as a user with
the appropriate privileges the are two options for setting UTL_FILE_DIR :

a. Mapped Drive : To use a mapped drive, the user that the service starts as
must have setup a drive to match UTL_FILE_DIR and be logged onto the server
when UTL_FILE is in use.

b. Universal Naming Convention : UNC is preferable to Mapped Drives because
it does not require anyone to be logged on and UTL_FILE_DIR should be set to
a name in the form :

  \\\<machine name>\<share name>\<path>


  "\\<machine name>\<share name>\<path>"
LVL 14

Assisted Solution

GGuzdziol earned 100 total points
ID: 17866627
db_server_remote - just made an expariment
LVL 27

Assisted Solution

sujith80 earned 60 total points
ID: 17866740
The file will be opened in the machine where the database is hosted.
I.e. if you are running the procedure using a db_link: the file will be opened in the machine where the database pointed thru the db link is residing.
LVL 35

Assisted Solution

by:Mark Geerlings
Mark Geerlings earned 90 total points
ID: 17868981
If the procedure is a remote procedures that you run via a database link, then the file that utl_file creates will also be on the remote server (the server where the procedure is a local procedure).

Author Comment

ID: 17869082
Thanks for the great help!  Will split.

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

707 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