Go Premium for a chance to win a PS4. Enter to Win

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

Metadata

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
msimons4
Asked:
msimons4
  • 7
  • 4
  • 4
8 Solutions
 
slightwv (䄆 Netminder) Commented:
Try an upper case 'W' to open for Write.
0
 
msimons4Author Commented:
I did, but same results. Any other ideas?
0
 
sdstuberCommented:
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!

 
slightwv (䄆 Netminder) Commented:
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
 
sdstuberCommented:
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
 
slightwv (䄆 Netminder) Commented:
>>it should support strings up to 32767

correct.  I forgot PL/SQL could handle 32K.
0
 
msimons4Author Commented:
It should have write privileges since the /u01 mount point has:

chown -R oracle:oinstall /u01
chmod -R 775 /u01
0
 
sdstuberCommented:
and DATA_MODEL points to /uo1?
0
 
msimons4Author Commented:
Yes, DATA_MODEL is down a couple of directories in this mount point.
0
 
sdstuberCommented:
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
 
sdstuberCommented:
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
 
slightwv (䄆 Netminder) Commented:
>>If you do try to write a CLOB with length greater than 32767  you'll get

Thanks for clarifying.
0
 
sdstuberCommented:
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
 
msimons4Author Commented:
Thanks
0
 
sdstuberCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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