출처: http://blog.naver.com/openkim/100005883749


SQL*PLUS 에서 HTML 형식의 output file 을 생성하는 방법에 대해 소개한다.

V8.1.6 이상부터 SQL*PLUS 내에서 HTML 을 생성하는 것이 가능한다. 다음의 자료는 HTML 생성의 가능성에 대한 전반적인 설명과 기능을 설명한다. 이것은 SQL*PLUS 모든 tag가 어떤 code변화 없이 HTML 로 변환될 수 있기 때문에 CHARACTER mode 로부터 HTML 로 migration 하기에 용이하다. ( TTITLE, BTITILE, ..)


예제1) dept table 의 내용을 html table 형식으로 받기

   set markup html on spool on
   spool ex1.html
   select * from dept;
   spool off
   set markup html off spool off


예제2) report 의 caption 르 수정하기

   set markup html on spool on HEAD '<TITLE> Second Test SQL*Plus and HTML </TITLE>'
   spool ex2.html
   select * from emp;    
   spool off
   set markup html off spool off


예제3) script 에 title 과 footer 추가하기

   set markup html on spool on HEAD '<TITLE> Third Test SQL*Plus and HTML </TITLE>'
   spool ex3.html

   TTITLE CENTER 'All rows from Dept' Skip 1 Left 'Left arranged' Right 'right arranged' Skip 3
   BTITLE CENTER 'End of report' Skip 3

   select * from emp;

   spool off
   set markup html off spool off


예제4) Background color 를 검정으로 text color 를 분홍으로 바꾸기

   set markup html on spool on HEAD '<TITLE> Forth Test SQL*Plus and HTML </TITLE>' -
   Body 'TEXT=hotpink bgcolor=black'
   spool ex4.html

   TTITLE CENTER 'All rows from Dept' Skip 1 Left 'Left arranged' Right 'right arranged' Skip 3
   BTITLE CENTER 'End of report' Skip 3
  
   select * from dept; 

   spool off
   set markup html off spool off


예제5) table attribute 를 바꾸기

   set markup html on spool on HEAD '<TITLE> Fifth Test SQL*Plus and HTML </TITLE>' -
   Body 'TEXT=hotpink bgcolor=black'-
   TABLE 'align=center width=50% border=10 bordercolor=green bgcolor=white'
   spool ex5.html

   TTITLE CENTER 'All rows from Dept' Skip 1 Left 'Left arranged' Right 'right arranged' Skip 3
   BTITLE CENTER 'End of report' Skip 3
   
   select * from dept;

   spool off
   set markup html off spool off


예제6) Table 에 style 을 넣기

   set markup html on spool on HEAD '<TITLE> Sixth Test SQL*Plus and HTML </TITLE> -
       <Style type="text/css"> -
       <!-- p.style1  {text-align: center; color: blue} --> -
       </Style>' -
    Body 'TEXT=hotpink bgcolor=black'-
    TABLE 'style="p class=style1" align=center width=50% border=10 bordercolor=green bgcolor=white'
    spool ex6.html

    TTITLE CENTER 'All rows from Dept' Skip 1 Left 'Left arranged' Right 'right arranged' Skip 3
    BTITLE CENTER 'End of report' Skip 3

    column A heading "Department Name"
    column B heading "Location" 

    select '<p class=style1>'||DNAME||'</p>' A,'<p class=style1>'||loc||'</p>' B from dept;

   spool off 
   set markup html off spool off

 

+ Recent posts