Solved

Metadata

Posted on 2011-02-28
15
484 Views
Last Modified: 2012-05-11
I'm trying to write the metadata results from DBMS_METADATA.get_dependent_ddl to a file, but am getting errors.

declare

v_file_handle UTL_FILE.file_type;
indexes_metadata VARCHAR2(50);

begin


v_file_handle := UTL_FILE.fopen('DATA_MODEL', 'DDL_' || indexes_metadata || '.sql', 'w', 32767);

FOR cur_rep IN
(SELECT DBMS_METADATA.get_dependent_ddl ('INDEX', 'TABLE_NAME', 'SCHEMA_NAME')  output from dual
)

LOOP

UTL_FILE.put_line(v_file_handle, cur_rep.output);

END LOOP;



UTL_FILE.fclose(v_file_handle);

end;

/



ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation
ORA-06512: at line 9
0
Comment
Question by:msimons4
[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
  • 7
  • 4
  • 4
15 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34997104
Try an upper case 'W' to open for Write.
0
 

Author Comment

by:msimons4
ID: 34997129
I did, but same results. Any other ideas?
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 375 total points
ID: 34997205
Does Oracle have write permission on the DATA_MODEL   file system directory?  

not the user read/write GRANT in oracle, but in the OS
0
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 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34997258
Apologizes.  I thought the mode was case sensitive.

The problem might be that get_dependent_ddl  returns a CLOB and put_line accepts a varchar2.

I'm not sure what error utl_file will generate if it tires to write a buffer with over 4000 characters in it.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 375 total points
ID: 34997277
since the file was opened with 32767  line length,  it should support strings up to 32767

of course, if the clob is longer than that you may run into a problem,  or if the underlying operating system won't allow a line length that size but  I can't think of any off hand.
0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 125 total points
ID: 34997290
>>it should support strings up to 32767

correct.  I forgot PL/SQL could handle 32K.
0
 

Author Comment

by:msimons4
ID: 34997294
It should have write privileges since the /u01 mount point has:

chown -R oracle:oinstall /u01
chmod -R 775 /u01
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 375 total points
ID: 34997366
and DATA_MODEL points to /uo1?
0
 

Author Comment

by:msimons4
ID: 34997575
Yes, DATA_MODEL is down a couple of directories in this mount point.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 375 total points
ID: 34998124
are you sure all of your permissions are correct?
and the directory name is correct, remember the strings are case sensitive.

'/U01'   is not the same thing as '/u01'


your code runs for me (with appropriate schema and table name inserted)
so the syntax is correct

the error is coming from the OS

maybe the filesystem is full?
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 375 total points
ID: 34998521
If you do try to write a CLOB with length greater than 32767  you'll get

ORA-06502: PL/SQL: numeric or value error


0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 125 total points
ID: 34998545
>>If you do try to write a CLOB with length greater than 32767  you'll get

Thanks for clarifying.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 375 total points
ID: 35018932
fyi,
your questions will close immediately if you don't accept your own post.
and since your post wasn't actually part of the answer, it didn't need accepted anyway

I'm not objecting to the close, just pointing it out for your future questions.

glad we could help
0
 

Author Comment

by:msimons4
ID: 35018977
Thanks
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 35019017
you didn't need to accept my comment about how to close as part of the answer , because it clearly wasn't.

glad we could help,

but for future questions,  it's best to just accept the posts that contribute to your answer
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.

738 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