Solved

Metadata

Posted on 2011-02-28
15
477 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
  • 7
  • 4
  • 4
15 Comments
 
LVL 76

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 73

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
 
LVL 76

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 73

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 76

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
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 73

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 73

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 73

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 76

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 73

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 73

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

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database

760 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