Question: I want to be able to read and write to a PC client using text_io. I cannot use utl_file because I do not have Oracle database installed on the remote client. How do I invoke text_io?
Answer: The Oracle text_io package can write to the local machine rather than server side (such as utl_file).
Here is an example of using the text_io utility to write across platforms. This is invoked from the Oracle server and writes to the connected remote PC client:
declare
l_out_file text_io.file_type;
begin
l_out_file := text_io.fopen( 'c:\text.txt', 'w' ); -- w is write, r is read
text_io.put (l_out_file, 'New text' );
text_io.new_line( l_out_file, 1 ); -- 1 new line
text_io.fclose( l_out_file );
end;/
To check, if file exists or not on server's directory
DECLARE
v_file Text_IO.File_Type;
BEGIN
v_file := Text_IO.Fopen('C:\Photos\myphoto.jpg', 'r');
message('success'); message('');
EXCEPTION
WHEN OTHERS THEN
message('exception'); message('');
END;
No comments:
Post a Comment