Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

regarding the utl_file concept in oracle db

Posted on 2011-03-12
11
Medium Priority
?
432 Views
Last Modified: 2012-05-11
hi all,
i have one select query which fetching recods from 4-5 tables and i am getting 60000 records in that query, so i would like to use utl file and getting those records in the text file. for that what accesss do i need on the server,

i think can i use existing path /apps/orarpt file with read and write prilileges or do we need to bounce the db for utl file parameter.
0
Comment
Question by:nagavenuiluri
[X]
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
  • 5
  • 4
  • 2
11 Comments
 

Author Comment

by:nagavenuiluri
ID: 35120235
hi all,
after building procedure do i need to login to db and execute that, how should i proceedd.

pls help me on this
0
 
LVL 4

Expert Comment

by:subratabiswas
ID: 35120398
Relevant information about how to create, read, write files using utl_file, can be found at http://www.adp-gmbh.ch/ora/plsql/utl_file.html . It has two small but useful examples at the end.

There is no need to log out and log back in after creating a procedure / package; after creation or update, new versions of package / procedure are available immediately for execution in the same session. But if your account is assigned a new privilege (e.g. to create directory, or access to an existing directory), then it would be required to log out and reconnect in order for those new privileges to be effective.
0
 
LVL 4

Expert Comment

by:subratabiswas
ID: 35120423
It should be clear from the link above that you will need access to an existing directory, or create directory privilege. Files to be read / written are located on the server.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:nagavenuiluri
ID: 35120534
hi all,
do we need to bounce the database to setup utl file or it is aleady exists in the db, we are using 10g oracle.
0
 
LVL 4

Expert Comment

by:subratabiswas
ID: 35120881
Package UTL_FILE is part of the base installation of Oracle. If the database is running, it should be available for execution, no need to bounce any services.
0
 
LVL 4

Expert Comment

by:subratabiswas
ID: 35120917
UTL_FILE has been available since Oracle 7.3; there has been some enhancement to include support for DIRECTORY from Oracle 9i. prior to 9i, files could exist only in physical directories pointed to by parameter utl_file_dir; 9i onwards, it is possible to define a DIRECTORY object pointing to a physical directory and create / access files there using URL_FILE.
0
 
LVL 2

Expert Comment

by:swadhinray
ID: 35124785
As subratabiswas: said follow it and you dont need to bounce your DB is under SYS user you will find the UTL packages.

You need write a procedure which will execute the sql statement and export it into a txt or other file format that you want.

You can also use do spool to your query and save it for an example check this link:
http://www.experts-exchange.com/Database/Software/CRM/Oracle/Q_24107028.html

Else if you want you can also implement the UTL file concept.

0
 

Author Comment

by:nagavenuiluri
ID: 35124925
if i need to execute the procedure in sql so i need the schema privilges with create option right?
0
 

Author Comment

by:nagavenuiluri
ID: 35124940
Thanks for ur responces.
i mean schema credentials and for that schema it should have create priviliges am i right
0
 
LVL 2

Expert Comment

by:swadhinray
ID: 35125166
if you need to execute then  you need to have execute privileges to on user  and if you wan to create then you need create privileges to you user.

As a sysdba you can grant all the required privileges to your user.
0
 
LVL 4

Accepted Solution

by:
subratabiswas earned 2000 total points
ID: 35125517
One thing to be highlighted, if not clear already by now, it is not enough to have the path /apps/orarpt existing at the OS level; it is also required to have that path included in parameter UTL_FILE_DIR or to create a DIRECTORY database object pointing to that directory.
0

Featured Post

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!

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

670 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