?
Solved

Metadata

Posted on 2011-02-28
15
Medium Priority
?
486 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 1500 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
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!

 
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 1500 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 500 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 1500 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 1500 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 1500 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 500 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 1500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses

801 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