S
S
sarsaparilla2017-03-10 13:40:14
Oracle
sarsaparilla, 2017-03-10 13:40:14

How to write data to a file using UTL_FILE?

Do not judge strictly, there is no experience.
I do something like this, only instead of txt I have a csv file.
begin
4 v_handle := Utl_File.Fopen(location => 'EXPGG',
5 filename => 'test.txt',
6 open_mode => 'w',
7 max_linesize => 32767);
8 for z in (select val from tst) loop
9 Utl_File.put_line(v_handle, z.val);
10 end-loop;
11 Utl_File.FClose(v_handle);
12 end;
But I have several fields in tst and I need them all when I just enumerate in a loop,
9 Utl_File.put_line(v_handle, z.val1, z.val2, etc);
then the error appears PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
Would it be correct to do so for z in (select ||'"'||val1||'";"'||val2||'" ;"'|| etc. from tst) loop ??
Or is it somehow done differently? Does each value need to be wrapped in quotes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2017-04-18
@idShura

export to CSV (Tom Kyte)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question