~ubuntu-branches/ubuntu/trusty/orafce/trusty-proposed

« back to all changes in this revision

Viewing changes to sql/files.sql

  • Committer: Bazaar Package Importer
  • Author(s): Peter Eisentraut
  • Date: 2007-10-17 18:50:39 UTC
  • Revision ID: james.westby@ubuntu.com-20071017185039-0jn7u57revfenvym
Tags: upstream-2.1.2
ImportĀ upstreamĀ versionĀ 2.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
create or replace function gen_file() returns void as $$
 
2
declare 
 
3
  f utl_file.file_type;
 
4
  r record;
 
5
begin
 
6
  f := utl_file.fopen('/tmp','regress_orafce','w');
 
7
  for r in select m from generate_series(1,20) m(m) loop
 
8
    perform utl_file.put_line(f, r.m::numeric);
 
9
  end loop;
 
10
  f := utl_file.fclose(f);
 
11
end;
 
12
$$ language plpgsql;
 
13
select gen_file();
 
14
 
 
15
 
 
16
create or replace function read_file() returns void as $$
 
17
declare 
 
18
  f utl_file.file_type;
 
19
begin
 
20
  f := utl_file.fopen('/tmp','regress_orafce','r');
 
21
  loop 
 
22
    raise notice '>>%<<', utl_file.get_line(f);
 
23
  end loop;
 
24
  exception
 
25
    -- when no_data_found then,  8.1 plpgsql doesn't know no_data_found
 
26
    when others then
 
27
      raise notice 'finish % ', sqlerrm;
 
28
      raise notice 'kuku';
 
29
      f := utl_file.fclose(f);
 
30
      raise notice 'bbbb';
 
31
end;
 
32
$$ language plpgsql;
 
33
select read_file();