[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3245
  • Last Modified:

execute stored procedure to UTL_FILE FOPEN via db link

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
ewang1205
Asked:
ewang1205
5 Solutions
 
cgilbert78frCommented:
Hi !

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

Regards
0
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
i think it should be in unix_remote only. But i have never done it or tested it.

Thanks
0
 
ewang1205Author Commented:
Any other expert opinion?  Thanks.
0
Industry Leaders: 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!

 
schwertnerCommented:
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
 
GGuzdziolCommented:
db_server_remote - just made an expariment
0
 
sujith80Commented:
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
 
Mark GeerlingsDatabase AdministratorCommented:
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
 
ewang1205Author Commented:
Thanks for the great help!  Will split.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now