SAK }‘ŠŲ

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠŲEƒJƒtƒF ˆę—— SAK Streets ŒŸõ
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

Oracle PL/SQL utl_file.fopenAget_lineAputAnew_lineAput_lineAputfAfflush

Oracle9i - 9.0.1 ‚Å‹@”\Šg’Ģ‚ ‚č

ĄFOPEN ƒeƒLƒXƒgƒtƒ@ƒCƒ‹ƒI[ƒvƒ“

  fno := utl_file.fopen('g:\tmp', 'test.txt', 'R', 4002);
  |                      |         |           |   |_ ƒŒƒR[ƒh’·
  |                      |         |           |      (in binary_integer)
  |                      |         |           |      ‰üs‚āŠÜ‚ÞƒoƒCƒg’·
  |                      |         |           |      1 ` 32767
  |                      |         |           |      ŒÃ‚Ē Oracle ‚Å‚Í
  |                      |         |           |      Žw’č‚·‚é‚ƃGƒ‰[
  |                      |         |           |      Č—Š’l‚Í 1023
  |                      |         |           |_ “üo—̓‚[ƒh(in varchar2)
  |                      |         |              R read  (“ü—Í)
  |                      |         |              W write (o—Í)
  |                      |         |              A append(’Į‰Áo—Í)
  |                      |         |_ ƒtƒ@ƒCƒ‹–ž(in varchar2)
  |                      |_ ƒpƒX(in varchar2)
  |_ –ß‚č’l(file_type)
     ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹

ĄFOPEN_NCHAR ƒeƒLƒXƒgƒtƒ@ƒCƒ‹ UNICODE ƒI[ƒvƒ“

  fno := utl_file.fopen_nchar('g:\tmp', 'test.txt', 'R', 4002);
  |                            |         |           |   |_ ƒŒƒR[ƒh’·
  |                            |         |           |    (in binary_integer)
  |                            |         |           |      ‰üs‚āŠÜ‚Þ•ķŽš”
  |                            |         |           |      1 ` 32767
  |                            |         |           |      ŒÃ‚Ē Oracle ‚Å‚Í
  |                            |         |           |      Žw’č‚·‚é‚ƃGƒ‰[
  |                            |         |           |      Č—Š’l‚Í 1023
  |                            |         |           |_ “üo—̓‚[ƒh
  |                            |         |              (in varchar2)
  |                            |         |              R read  (“ü—Í)
  |                            |         |              W write (o—Í)
  |                            |         |              A append(’Į‰Áo—Í)
  |                            |         |_ ƒtƒ@ƒCƒ‹–ž(in varchar2)
  |                            |_ ƒpƒX(in varchar2)
  |_ –ß‚č’l(file_type)
     ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹

ĄIS_OPEN ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹’ēļ

  rcd := utl_file.is_open(fno);
  |                       |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(file_type)
  |_ –ß‚č’l(boolean)
     TRUE  = —LŒø
     FALSE = –ģŒø

ĄFCLOSE ƒeƒLƒXƒgƒtƒ@ƒCƒ‹ƒNƒ[ƒY

  utl_file.fclose(fno);
                  |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in out file_type)

ĄFCLOSE_ALL ‘SƒeƒLƒXƒgƒtƒ@ƒCƒ‹ƒNƒ[ƒY

  utl_file.fclose_all;

ĄGET_LINE 1 sƒŠ[ƒh

  utl_file.get_line(fno, rec);
                    |    |_ ƒeƒLƒXƒgƒŒƒR[ƒh(out varchar2)
                    |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

declare

  fno  utl_file.file_type;  -- ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹
  rec  varchar2(2000);      -- “ü—̓oƒbƒtƒ@

begin

-- ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“
  fno := utl_file.fopen('g:\tmp', 'test.txt', 'R', 2002);

-- ƒŠ[ƒhƒ‹[ƒv
  begin
    loop
      utl_file.get_line(fno, rec);
      dbms_output.put_line(rec);
    end loop;
  exception
    when NO_DATA_FOUND then  -- ƒŒƒR[ƒh AT END
      dbms_output.put_line('ģíI—đ');
    when OTHERS then
      dbms_output.put_line('** ƒŠ[ƒhƒGƒ‰[');
  end;

-- ƒtƒ@ƒCƒ‹ƒNƒ[ƒY
  utl_file.fclose(fno);

end;
/

ĄGET_LINE_NCHAR 1 s UNICODE ƒŠ[ƒh

  utl_file.get_line_nchar(fno, rec);
                          |    |_ ƒeƒLƒXƒgƒŒƒR[ƒh(out nvarchar2)
                          |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

ĄPUT •ķŽš—ņƒ‰ƒCƒg

  utl_file.put(fno, rec);
               |    |_ ƒeƒLƒXƒgƒŒƒR[ƒh(in varchar2)
               |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

ĄPUT_NCHAR •ķŽš—ņ UNICODE ƒ‰ƒCƒg

  utl_file.put_nchar(fno, rec);
                     |    |_ ƒeƒLƒXƒgƒŒƒR[ƒh(in nvarchar2)
                     |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

ĄNEW_LINE ‰üsƒR[ƒhƒ‰ƒCƒg

  utl_file.new_line(fno, 1);
                    |    |_ ‰üsƒR[ƒhŒÂ”(in natural)
                    |       Č—Š’l‚Í 1
                    |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

ĄPUT_LINE 1 sƒ‰ƒCƒg

  utl_file.put_line(fno, rec);
                    |    |_ ƒeƒLƒXƒgƒŒƒR[ƒh(in varchar2)
                    |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

declare

  fno  utl_file.file_type;  -- ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹
  rec  varchar2(2000);      -- o—̓oƒbƒtƒ@

begin

-- ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“
  fno := utl_file.fopen('g:\tmp', 'test.txt', 'W', 2002);

-- ƒ‰ƒCƒg
  begin
    utl_file.put_line(fno, '‘‚Ŧž‚݃eƒXƒg');
    utl_file.put_line(fno, '0123456789');
    rec := to_char(sysdate, 'yyyy.mm.dd hh24:mi:ss');
    rec := 'abc ' || rec || ' def';
    utl_file.put_line(fno, rec);
  exception
    when OTHERS then
      dbms_output.put_line('** ƒ‰ƒCƒgƒGƒ‰[');
  end;

-- ƒtƒ@ƒCƒ‹ƒNƒ[ƒY
  utl_file.fclose(fno);

end;
/

-- test.txt o—ÍŒ‹‰Ę --
‘‚Ŧž‚݃eƒXƒg
0123456789
abc 2002.07.01 17:07:45 def

ĄPUT_LINE_NCHAR 1 s UNICODE ƒ‰ƒCƒg

  utl_file.put_line_nchar(fno, rec);
                          |    |_ ƒeƒLƒXƒgƒŒƒR[ƒh(in nvarchar2)
                          |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

ĄPUTF ‘ŽŪ–„‚ߍž‚݃‰ƒCƒg

  utl_file.putf(fno, format, arg1, arg2...);
                |    |       |     |_ format ‚Ė–„‚ߍž‚݈ø”‚ĖŒÂ”•ŠŽw’č
                |    |       |        Å‘å’l 5 ŒÂ
                |    |       |_ format ‚Ė–„‚ߍž‚Ý‘æˆęˆø”ŠY“–ƒf[ƒ^
                |    |          (in varchar2) Č—Š’l‚Í NULL
                |    |_ ‘ŽŪ•ķŽš—ņ(in varchar2)
                |       \n  ‰üsƒR[ƒh
                |       %s  –„‚ߍž‚݈ø”
                |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

declare

  fno  utl_file.file_type;  -- ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹
  rec  varchar2(2000);      -- o—̓oƒbƒtƒ@

begin

-- ƒtƒ@ƒCƒ‹ƒI[ƒvƒ“
  fno := utl_file.fopen('g:\tmp', 'test.txt', 'W', 2002);

-- ƒ‰ƒCƒg
  begin
    rec := to_char(sysdate, 'yyyy.mm.dd hh24:mi:ss');
    utl_file.putf(fno, '‘‚Ŧž‚݃eƒXƒg\n%s\nabc %s def\n',
      '0123456789', rec);
  exception
    when OTHERS then
      dbms_output.put_line('** ƒ‰ƒCƒgƒGƒ‰[');
  end;

-- ƒtƒ@ƒCƒ‹ƒNƒ[ƒY
  utl_file.fclose(fno);

end;
/

-- test.txt o—ÍŒ‹‰Ę --
‘‚Ŧž‚݃eƒXƒg
0123456789
abc 2002.07.01 17:07:52 def

ĄPUTF_NCHAR ‘ŽŪ–„‚ߍž‚Ý UNICODE ƒ‰ƒCƒg

  utl_file.putf_nchar(fno, format, arg1, arg2...);
                      |    |       |     |_ format ‚Ė–„‚ߍž‚݈ø”‚ĖŒÂ”•ŠŽw’č
                      |    |       |        Å‘å’l 5 ŒÂ
                      |    |       |_ format ‚Ė–„‚ߍž‚Ý‘æˆęˆø”ŠY“–ƒf[ƒ^
                      |    |          (in nvarchar2) Č—Š’l‚Í NULL
                      |    |_ ‘ŽŪ•ķŽš—ņ(in nvarchar2)
                      |       \n  ‰üsƒR[ƒh
                      |       %s  –„‚ߍž‚݈ø”
                      |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

ĄFFLUSH ‘‚Ŧž‚݃oƒbƒtƒ@‘ĶŽžo—Í

  utl_file.fflush(fno);
                  |_ ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹(in file_type)

  ** FFLUSH ‚́A’ʏíŽg—p‚·‚é•K—v‚Č‚ĩB

Ą—áŠO

  INVALID_PATH         ƒpƒXA‚Ü‚―‚́Aƒtƒ@ƒCƒ‹–ž‚Š–ģŒø
  INVALID_MODE         ƒI[ƒvƒ“ƒ‚[ƒh‚Š–ģŒø
  INVALID_FILEHANDLE   ƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹‚Š–ģŒø
  INVALID_OPERATION    ƒtƒ@ƒCƒ‹‘€ė‚Š–ģŒø
  INVALID_MAXLINESIZE  Žw’čƒŒƒR[ƒh’·‚Š‘å‚Ŧ‚·‚Ž‚é‚ЁAŽ‚ģ‚·‚Ž‚é
  READ_ERROR           ƒtƒ@ƒCƒ‹ƒŠ[ƒhƒGƒ‰[
  WRITE_ERROR          ƒtƒ@ƒCƒ‹ƒ‰ƒCƒgƒGƒ‰[
  INTERNAL_ERROR       PL/SQL “ā•”ƒGƒ‰[
  CHARSETMISMATCH      fopen_nchar ‚ŁAnchar ‚Å‚Č‚Ē‘€ė‚ðs‚Á‚―
  VALUE_ERROR          “Į‚ݍž‚݃ŒƒR[ƒh’·‚Šƒoƒbƒtƒ@‚æ‚č‘å‚Ŧ‚Ē
  NO_DATA_FOUND        ƒŠ[ƒhƒf[ƒ^‚Č‚ĩ

ĄOracle PL/SQL •ŌŽ‘—ŋ
ĄSQL Šî‘bŽĀ’n•ŌŽ‘—ŋ
ĄSQL Šî‘b•ŌŽ‘—ŋ
ĄSQL ƒ`ƒ…[ƒjƒ“ƒO•ŌŽ‘—ŋ
ĄPostgreSQL •ŌAJAVA ServletAJSP •ŌŽ‘—ŋ
ĄMySQL •ŌŽ‘—ŋ
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠŲEƒJƒtƒF ˆę—— SAK Streets ŒŸõ



Copyright (C) 1999-2017 Y.SAK