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 •Ò15 - ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê—— CSV o—́AHTML o—Í

¡ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê—— CSV o—Í

  EŽŸ‚̃Tƒ“ƒvƒ‹‚́Aƒ†[ƒUƒIƒuƒWƒFƒNƒg‚̈ꗗ‚ð CSV Œ`Ž®‚ÉŒ©o‚µ•t‚«‚ŏo
    —Í‚µ‚Ü‚·BCSV ‚̏o—ÍŒ`Ž®‚́A‹æØ‚è‹L†‚ɃJƒ“ƒ}u,vAˆø—p‹å‚Ƀ_ƒtƒ‹
    ƒR[ƒe[ƒVƒ‡ƒ“u"v‚ðŽg—p‚µ‚Ä‚¢‚Ü‚·B
    (‚·‚ׂẴe[ƒuƒ‹A‘S‚Ẵe[ƒuƒ‹A“o˜^‚³‚ê‚Ä‚¢‚éƒe[ƒuƒ‹A•\ˆê——Aƒe[ƒuƒ‹–¼•\Ž¦)
    (‚·‚ׂẴrƒ…[A‘S‚Ẵrƒ…[A“o˜^‚³‚ê‚Ä‚¢‚éƒrƒ…[Aƒrƒ…[ˆê——)
    (‚·‚ׂẴpƒbƒP[ƒWA‘S‚ẴpƒbƒP[ƒWA“o˜^‚³‚ê‚Ä‚¢‚éƒpƒbƒP[ƒWAƒpƒbƒP[ƒWˆê——)
    (‚·‚ׂẴXƒgƒAƒhƒvƒƒVƒWƒƒA‘S‚ẴXƒgƒAƒhƒvƒƒVƒWƒƒ)
    (“o˜^‚³‚ê‚Ä‚¢‚éƒXƒgƒAƒhƒvƒƒVƒWƒƒAƒXƒgƒAƒhƒvƒƒVƒWƒƒˆê——)

declare

  dnm  varchar2(200) := 'g:\tmp';    -- ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê——o—̓pƒX
  fnm  varchar2(200) := 'test.csv';  -- ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê——o—̓tƒ@ƒCƒ‹–¼

  cursor cu is select
    lower(object_name) as ƒIƒuƒWƒFƒNƒg,
    lower(object_type) as ƒ^ƒCƒv,
    to_char(created, 'yyyy.mm.dd hh24:mi:ss') as ì¬“ú•t,
    to_char(last_ddl_time, 'yyyy.mm.dd hh24:mi:ss') as XV“ú•t
    from user_objects
    order by object_type, object_name;

  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(dnm, fnm, 'W', 2002);

-- Œ©o‚µƒ‰ƒCƒg
  utl_file.putf(fno, '"%s","%s","%s","%s"\n',
    'ƒ^ƒCƒv', 'ƒIƒuƒWƒFƒNƒg', 'ì¬“ú•t', 'XV“ú•t');

-- ƒ‰ƒCƒg
  begin
    for cu_rec in cu loop
      utl_file.putf(fno, '"%s","%s","%s","%s"\n',
        cu_rec.ƒ^ƒCƒv, cu_rec.ƒIƒuƒWƒFƒNƒg,
        cu_rec.ì¬“ú•t, cu_rec.XV“ú•t);
    end loop;
  exception
    when OTHERS then
      dbms_output.put_line('** ƒ‰ƒCƒgƒGƒ‰[');
  end;

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

end;
/

-- test.csv o—ÍŒ‹‰Ê --
"ƒ^ƒCƒv","ƒIƒuƒWƒFƒNƒg","ì¬“ú•t","XV“ú•t"
"function","gettmp","2002.01.05 13:01:35","2002.03.02 19:03:09"
"index","sys_c002112","2002.01.05 13:01:52","2002.01.05 13:01:52"
"index","sys_c002113","2002.01.05 13:01:11","2002.01.05 13:01:11"
"table","ipm","2002.01.05 14:01:49","2002.01.05 14:01:49"
"table","msgm","2002.01.05 13:01:05","2002.01.05 13:01:05"
"table","ƒR[ƒhm","2002.01.05 13:01:36","2002.01.05 13:01:36"
"table","ƒeƒXƒgm","2002.01.05 13:01:28","2002.01.05 13:01:28"
"view","msgv1","2002.01.05 13:01:06","2002.01.05 13:01:06"

¡ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê—— HTML o—Í

  EŽŸ‚̃Tƒ“ƒvƒ‹‚́Aƒ†[ƒUƒIƒuƒWƒFƒNƒg‚̈ꗗ‚ð HTML Œ`Ž®‚ɏo—Í‚µ‚Ü‚·B

declare

  dnm  varchar2(200) := 'g:\tmp';    -- ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê——o—̓pƒX
  fnm  varchar2(200) := 'test.htm';  -- ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê——o—̓tƒ@ƒCƒ‹–¼

  cursor cu is select
    lower(object_name) as ƒIƒuƒWƒFƒNƒg,
    lower(object_type) as ƒ^ƒCƒv,
    to_char(created, 'yyyy.mm.dd hh24:mi:ss') as ì¬“ú•t,
    to_char(last_ddl_time, 'yyyy.mm.dd hh24:mi:ss') as XV“ú•t
    from user_objects
    order by object_type, object_name;

  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(dnm, fnm, 'W', 2002);

-- HTML ƒwƒbƒhƒ‰ƒCƒg
  utl_file.put_line(fno, '<HTML>');
  utl_file.put_line(fno, '<HEAD>');
  utl_file.put_line(fno, '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">');
  utl_file.put_line(fno, '</HEAD>');
  utl_file.put_line(fno, '<BODY>');
  utl_file.put_line(fno, '<CENTER>');
  utl_file.put_line(fno, '<TABLE border=1 bordercolordark=White bordercolorlight=#a0a0a0 cellPadding=3 cellSpacing=0>');
  utl_file.put_line(fno, '<TBODY bgcolor=#f0f0f0 align="left">');
  utl_file.put_line(fno, '<TR bgcolor=#d0d0d0 align="center">');
  utl_file.put_line(fno, '<TD colspan="4">ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê——</TD>');
  utl_file.put_line(fno, '</TR>');
  utl_file.put_line(fno, '<TR bgcolor=#d0d0d0 align="center">');
  utl_file.put_line(fno, '<TD>ƒ^ƒCƒv</TD>');
  utl_file.put_line(fno, '<TD>ƒIƒuƒWƒFƒNƒg</TD>');
  utl_file.put_line(fno, '<TD>ì¬“ú•t</TD>');
  utl_file.put_line(fno, '<TD>XV“ú•t</TD>');
  utl_file.put_line(fno, '</TR>');

-- HTML ƒ{ƒfƒBƒ‰ƒCƒg
  begin
    for cu_rec in cu loop
      utl_file.putf(fno,
        '<TR><TD>%s</TD><TD>%s</TD><TD>%s</TD><TD>%s</TD></TR>\n',
        cu_rec.ƒ^ƒCƒv, cu_rec.ƒIƒuƒWƒFƒNƒg, cu_rec.ì¬“ú•t, cu_rec.XV“ú•t);
    end loop;
  exception
    when OTHERS then
      dbms_output.put_line('** ƒ‰ƒCƒgƒGƒ‰[');
  end;

-- HTML ƒeƒCƒ‹ƒ‰ƒCƒg
  utl_file.put_line(fno, '</TBODY>');
  utl_file.put_line(fno, '</TABLE>');
  utl_file.put_line(fno, '</CENTER>');
  utl_file.put_line(fno, '</BODY>');

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

end;
/

-- test.htm ƒuƒ‰ƒEƒYƒCƒ[ƒW --
ƒ†[ƒUƒIƒuƒWƒFƒNƒgˆê——
ƒ^ƒCƒv ƒIƒuƒWƒFƒNƒg ì¬“ú•t XV“ú•t
functiongettmp2002.01.05 13:01:352002.03.02 19:03:09
indexsys_c0021122002.01.05 13:01:522002.01.05 13:01:52
indexsys_c0021132002.01.05 13:01:112002.01.05 13:01:11
tableipm2002.01.05 14:01:492002.01.05 14:01:49
tablemsgm2002.01.05 13:01:052002.01.05 13:01:05
tableƒR[ƒhm2002.01.05 13:01:362002.01.05 13:01:36
tableƒeƒXƒgm2002.01.05 13:01:282002.01.05 13:01:28
viewmsgv12002.01.05 13:01:062002.01.05 13:01:06
¡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