With the old C/S versions, the TEXT_IO package allowed to manipulate text files on the client machine.
Since the Web versions, this package allows to manipulate text files on the Application Server machine.
To allow developers to manipulate text files on the client machine, the Webutil CLIENT_TEXT_IO equivalent was created.
These two packages are equivalent in term of functionality, but not in term of speed. The difference comes from the network roundtrips used to transfer the data from the server to the client machine.
On the following screenshot, you can see a Forms dialog that use both TEXT_IO and CLIENT_TEXT_IO functions.
On the left part, the text file is created on the client machine with the CLIENT_TEXT_IO functions. On the right part, the text file is created on the server machine with the TEXT_IO functions.
For this basic test case, we created a text file with 50 lines read from a database table.
It need 15 seconds to create this file on the client machine, but only one to create the file on the server machine and download it on the client machine.
So, don’t use the CLIENT_TEXT_IO functions, but generate the file on the server machine then download it on the client machine with the WEBUTIL_FILE_TRANSFER.AS_to_client() function.
This is the test table creation script:
CREATE TABLE TEST_TEXTIO ( CODE NUMBER(5) PRIMARY KEY ,COL1 VARCHAR2(50) ,COL2 VARCHAR2(50) ,COL3 VARCHAR2(50) ) BEGIN FOR i IN 1 .. 50 LOOP INSERT INTO TEST_TEXTIO VALUES ( i ,RPAD(TO_CHAR(i),40, TO_CHAR(i)) ,RPAD(TO_CHAR(i),40, TO_CHAR(i)) ,RPAD(TO_CHAR(i),40, TO_CHAR(i)) ); END LOOP ; END;
hi Francois, thanks for the post it gave me an alternate idea to my requiremnt. I wrote a java code in the oracle procedure to read a file and display the output. im able to succeed it by reading the file in server. Now i want the same code to be executed so as to read a file in the same path from the client machine? if so could you please guide me.<br />
Thanks in advance.<br />
Ravi teja
<br />
Hi,<br />
<br />
<br />
nice, short and helpful article, thanks for that.<br />
<br />
<br />
In addition to performance issues, I've come across a situation, where creating 3000+ records simply does not work (crashes), while doing it via text_io works no problem. So maybe you always<br />
should create on the AppServer, then move the file to the Client ?<br />
<br />
<br />
Yes, that's exacltly what this article says.<br />
<br />
<br />
<br />
M
Maciej Myrcha
16/11/2010 17:39
<br />
<br />
Hi Francois,<br />
<br />
<br />
I've read your article and have some questions: we try to save some DB records to a flat file and the performance is crucial here. 150,000 records make a about 15 MB file and while with<br />
client_text_io it takes 80 seconds, with text_io it is about 28 seconds. However when I've changed a loop a little bit not to save a file line by line, but instead creating a varchar2 variable to<br />
store lines and then save it to a file, performance od client_text_io is comparable with text_io on AS side. Plus you have to move the file from AS to client, which takes additional 15 secons.<br />
What's more surprising, the same trick (with variable) doesn't seem to work with text_io - the time doesn't change. So now I'm confused - do you have any new ideaas about I/O operations on<br />
client?<br />
<br />
<br />
sincerelly<br />
<br />
<br />
Maciej<br />
<br />
<br />
<br />
<br />
<br />
CLIENT_TEXT_IO add network roundtrips, reason why it takes more time to go. If you do the job on the AS with TEXT_IO, you don't have the roundtrips, so that reducing the loop does not change<br />
anything.<br />
<br />
<br />
<br />
V
Vanessa Fernandez
07/05/2010 16:32
<br />
<br />
Hello,<br />
<br />
<br />
First of all I would like to thank you for sharing all this knowledge. I´m writing because I would like to ask for your advice on something. I need to save a .csv file on the client machine<br />
and I´m using webutil for that. I read your article about using WEBUTIL_FILE_TRANSFER.AS_to_client, and I´m trying to use it myself, but I´ve had no success.<br />
<br />
<br />
I have the database server on one machine and the application server on another one. The csv file is created on the database server through a package using the utl_file utilities. I created a G:<br />
drive in the application server to access the database server, in order to copy the file to the client. The copying code is this:<br />
<br />
<br />
WEBUTIL_FILE_TRANSFER.AS_to_client( l_client_filename, 'G:csv_name)<br />
<br />
<br />
The thing is that the file isn't copied, and when I try to capture the error I got: normal, succesfull completion. I've already changed the webutil.cfg, and given permissions to read G:. So<br />
I have no idea of what else to try. Could you please help on this? Thanks in advance,<br />
<br />
<br />
Vanessa<br />
<br />
<br />
<br />
Hi Francois,Thanks for your blog and it did help me a lot.What you wrote is what I want to know.I do appreciate what you have done. I do not know Frech but can read your english topics.Regards,Phil