output the result to a flat file in local PC [message #404283] |
Thu, 21 May 2009 04:37 |
ali560045
Messages: 25 Registered: May 2009
|
Junior Member |
|
|
i have a requirement in which i need to provide the client with the flat file containg some data of a PL/SQL . Below the code
begin
for record in (select * from employee where city='New York')
LOOP
dbms_output.put_line( record.FIRST_NAME || record.LAST_NAME );
END LOOP;
END;
Can anyone show me how shall i redirect the o/p of this PL/SQL to a flat file in my local PC
|
|
|
|
|
|
|
|
|
|
Re: output the result to a flat file in local PC [message #404296 is a reply to message #404283] |
Thu, 21 May 2009 05:01 |
ali560045
Messages: 25 Registered: May 2009
|
Junior Member |
|
|
i have found the below code, dnt know how to implement in the mentione PL/SQL. Please can anyone help
CREATE DIRECTORY test_dir AS 'c:\';
-- CREATE DIRECTORY test_dir AS '/tmp';
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('test_dir', 'test_file.txt', 'W');
UTL_FILE.PUTF(fileHandler, 'Writing TO a file\n');
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'ERROR: Invalid PATH FOR file.');
END;
/
[Updated on: Thu, 21 May 2009 05:02] Report message to a moderator
|
|
|
|
Re: output the result to a flat file in local PC [message #404300 is a reply to message #404283] |
Thu, 21 May 2009 05:05 |
ali560045
Messages: 25 Registered: May 2009
|
Junior Member |
|
|
The problem is i want to understand the concept of redirecting the o/p from a PL/SQL to a flatfile. So i posted a simple PL/SQL to understand how the logic works.
Hope everyone understood......
If anyone can provide a simple example related to PL/SQL that would do thanks
|
|
|
|
|
|
|
Re: output the result to a flat file in local PC [message #404316 is a reply to message #404283] |
Thu, 21 May 2009 05:34 |
ali560045
Messages: 25 Registered: May 2009
|
Junior Member |
|
|
i think i have mis-communicated . See the requirement is simple
1) I have Created the mentioned PL/SQL In My PC where oracle 9i is installed
2) Using the PL/SQL i want to get its result in flat file which should be located in my LOCAL drive C:\
3) I m not using any servers here just working on my local PC
If this simplifies the problem.....................
[Updated on: Thu, 21 May 2009 05:35] Report message to a moderator
|
|
|
|
Re: output the result to a flat file in local PC [message #404326 is a reply to message #404316] |
Thu, 21 May 2009 06:30 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
OK, so you found some code that uses utl_file. Have you tried it? played around with it? Had problems? got errors, researched the errors, found solutions, hit more errors, read up on them, didn't understand so decideed to post here? Or did you just find some code and hope that we would write some code for you?
|
|
|