Solved

execute stored procedure to UTL_FILE FOPEN via db link

Posted on 2006-11-03
8
3,106 Views
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.


0
Comment
Question by:ewang1205
8 Comments
 

Expert Comment

by:cgilbert78fr
ID: 17866471
Hi !

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

Regards
0
 
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.

Thanks
0
 

Author Comment

by:ewang1205
ID: 17866558
Any other expert opinion?  Thanks.
0
 
LVL 47

Accepted Solution

by:
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>

  or

  "\\<machine name>\<share name>\<path>"
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 14

Assisted Solution

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

Assisted Solution

by:sujith80
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.
0
 
LVL 34

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).
0
 

Author Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

757 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

20 Experts available now in Live!

Get 1:1 Help Now