Re: want to download .txt on unix server from form

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1998/09/29
Message-ID: <361bf964.96852977_at_192.86.155.100>#1/1


A copy of this was sent to Thenardier_at_POBoxes.com (if that email address didn't require changing) On Tue, 29 Sep 1998 09:05:03 GMT, you wrote:

>In article <3616c3a8.17560080_at_192.86.155.100>,
>> tkyte_at_us.oracle.com wrote:
>> Well, you could write a stored procedure that uses UTL_FILE to open and
>> read the the generated text file on the server and give back the file in
>> 32k pieces to the client.
>> so, if you write a package on the SERVER using UTL_FILE, you could achieve
>> this... You would call the package from forms and let forms use the TEXT_IO
>> client package to save the text locally for the user...
>> Or, if you have Oracle8 -- you can use the BFILE type to open and read the
>> file as well instead of using utl_file...
>
>thanx thomas, stored procedure created using UTL_FILE and it can read
>the text file. but i still donno how the TEXT_IO package can work with
>the stored proc. seems UTL_FILE can only save file within the its own
>platform instead of reaching the client's). and the same thing happens
>to TEXT_IO. so, the .txt file is still on the server and waiting for
>ur rescue. :-)
>
>thanx!
>
>rgds,
>thenard
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

Lets say that the file is less then 32k (if it is larger, you will have to change the API you write on the server to access the file in pieces).....

Write a stored procedure on the SERVER (stored in the database) that looks something like:

function get_file( p_path in varchar2, p_name in varchar2 ) return varchar2 as
  l_return_string varchar2(32000);
begin

        utl_file.fopen();
    loop

        utl_file.getline( the_line );
        exit when no more data
        l_return_string := l_return_string || the_line;
    end loop;
    ult_file.flclose();

    return l_return_string;
end;

And then IN THE FORM write a routine that looks like:

declare

    l_text varchar2(32000);
begin

    l_text := get_file( '/tmp/', 'somefilename.txt' );

    text_io.fopen();
    text_io.putl( l_text );
    text_io.fclose();

end;  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA

--
http://govt.us.oracle.com/    -- downloadable utilities
 
----------------------------------------------------------------------------
Opinions are mine and do not necessarily reflect those of Oracle Corporation
 
Anti-Anti Spam Msg: if you want an answer emailed to you, 
you have to make it easy to get email to you.  Any bounced
email will be treated the same way i treat SPAM-- I delete it.
Received on Tue Sep 29 1998 - 00:00:00 CEST

Original text of this message