Ok thanks. saya jg nemu beberapa dan skrg sudah bisa write file ke OS. On Tue, Dec 23, 2008 at 4:08 PM, chiank <[email protected]> wrote:
> 2008/12/23 Andes Febrian <[email protected] <pejantan4u%40gmail.com> > >: > > > Hi chiank.. > > > > Thanks for ur reply, it helps a lot. > > untuk menjalankan di sql developer, bisa kah berikan saya salah satu > contoh > > ? Thanks. > > > > ini contoh dari internet. moga membantu.. > > DECLARE > file_handle utl_file.file_type; -- file handle of OS flat file > > utl_dir VARCHAR2(255) := '/u01/utl_output'; > > col1 NUMBER; -- C1 retrieved from testtab table > retrieved_buffer VARCHAR2(100); -- Line retrieved from flat file > BEGIN > -- Open file to write into and obtain its file_handle. > --file_handle := utl_file.fopen(utl_dir,'myfile.txt','W',32767); > file_handle := utl_file.fopen(utl_dir,'myfile.txt','W'); > dbms_output.put_line('File opened for write'); > > -- Write a line of text out to the file. > utl_file.put_line(file_handle, 'this is line 1 as a test'); > dbms_output.put_line('Write 1 success'); > > -- Select the c1 from the testtab table where empno = 7900. > SELECT 10 INTO col1 FROM dual; > > -- Using PUTF write text with the col1 argument out to the file. > utl_file.putf(file_handle, 'This is the c1 %s when the c2 is > %s.\n', col1,'25'); > dbms_output.put_line('Write 2 success'); > > -- Close the file. > utl_file.fclose(file_handle); > dbms_output.put_line('File closed'); > > -- Open the same file to read from. > --file_handle := utl_file.fopen(utl_dir,'myfile.txt','R',32767); > file_handle := utl_file.fopen(utl_dir,'myfile.txt','R'); > dbms_output.put_line('File opened for read'); > > -- Read a line from the file. > utl_file.get_line(file_handle, retrieved_buffer); > dbms_output.put_line('Read success'); > > -- Print fetched line out to the SQL*Plus prompt. > dbms_output.put_line(retrieved_buffer); > > -- CLose the file. > utl_file.fclose(file_handle); > dbms_output.put_line('File closed'); > > END; > / > > -- > They say a rainbow appears after every storm > but my storms were caused by those who were my rainbows > > -- Cheers, ^_^ Andes ^_^ [Non-text portions of this message have been removed]

