Presentation is loading. Please wait.

Presentation is loading. Please wait.

Oracle Application Server 1999. 3. 5 DB Lab. 이재광.

Similar presentations


Presentation on theme: "Oracle Application Server 1999. 3. 5 DB Lab. 이재광."— Presentation transcript:

1 Oracle Application Server 1999. 3. 5 DB Lab. 이재광

2 2 목차 Application Server 의 발전 Application Server 의 활용 PL/SQL Application Server 의 HTML 문법 Summary

3 3 Application Server 의 발전 Oracle Web Application Server 1.0 Oracle Web Application Server 2.0 Oracle Web Application Server 3.0 –Oracle 7 을 기본 DBMS 로 사용 – 미약하지만 CORBA 지원 Oracle Application Server 4.0 – 디스패칭, 로드 - 밸런싱 및 써드파티 서버 확장자의 첨가를 위 한 고속 매커니즘인 Web Request Broker(WRB) 를 사용함 –Oracle 8 을 기반 DBMS 로 사용 –CORBA 2.0 지원

4 4 Application Server 의 활용 Application Server 4.0 는 CORBA 2.0 을 기준으로 만들어 졌고 CORBA 2.0 을 지원하기 때문에 대형, 또는 중형과 같은 노드 분산을 위한 Web Server 에 적당. 최근에 나온 Oracle 8 기반이기때문에 ORDB 를 지원 및 PL/SQL, SQL 등을 지원하므로 Web 개발 적용가능. Web 상으로 각종 조회, 수정 등 각종 DB 관련 업무 개 발에 편리

5 5 PL/SQL Web Cartridges Dispatcher Resource manager Application (cartridge server) … …. 1 6 2 3 4 5 Listener Web request Broker

6 6 PL/SQL 의 기본 (1) PL/SQL 의 프로시져 생성 예 ) create or replace procedure show_emp ( p_no number default 7900) is v_nameemp.ename%type; v_salemp.sal%type; begin select ename, sal intov_name, v_sal from emp where empno = p_no; htp.p(v_name||’, ’||v_sal||’ ’); end; 실행 : destiny.inchon.ac.kr/plsql/show_emp?p_no=7788 ahtp.p : Application Server 의 출력 명령 (C 에서의 printf)

7 7 PL/SQL 의 기본 (2) 예외 처리를 이용한 PL/SQL create or replace procedure show_emp (p_no number default 7900) is v_nameemp.ename%type; v_salemp.sal%type; begin select ename, v_sal into v_name, v_sal from emp where empno = p_no; htp.p(v_name||’, ‘||v_sal||’ ’); EXCEPTION WHEN NO_DATA_FOUND THEN htp.p(‘ 사원번호 ‘||p_no||’ 는 존재하지 않습니다 ’); WHEN OTHERS THEN htp.p(SQLERRM); end; 실행 : destiny.inchon.ac.kr/plsql/show_emp

8 8 PL/SQL 의 기본 (3) 여러 개의 Record 를 받는 방법 create or replace procedure display_emp is cursor emp_cursor is select e.empno, ename, sal, d.dname from emp e, dept d where e.deptno = d.deptno order by e.empno; begin for hrec in emp_cursor loop htp.p(hrec.ename||’, ‘||hrec.sal||’, ‘||hrec.dname||’ ’); end loop; end;

9 9 PL/SQL 의 기본 (4) OWA_UTIL.TABLEPRINT 를 이용한 PL/SQL create or replace procedure display_emp is dummy BOOLEAN; begin header(‘ 사원조회 ’); dummy := owa_util.TablePrint(‘emp, dept’, ‘BORDER’, OWA_UTIL.HTML_TABLE,’empno, ename, dname, sal’, ‘where emp.deptno = dept.deptno’, ‘ 사원번호, 사원명, 부서명, 급여 ’); footer; end;

10 10 PL/SQL 의 기본 (5) 결과

11 11 Application Server 의 HTML 문법 (1) Application Server 에는 PL/SQL 을 지원하기 위한 PL/SQL Web Toolkit 을 제공. –OWA_COOKIE, OWA_IMAGE, OWA_UTIL –OWA_OPT_LOCK, OWA_TEXT, OWA_CUSTOM –OWA_PATTERN –HTP(Hypertext procedures), HTF(Hypertext functions) –Customized extensions 모든 명령은 Package 형태로 지원.

12 12 Application Server 의 HTML 문법 (2) Procedure Call htp.header(1,’Overview’); htp.print(‘Hello Word’); htp.para; htp.bold(‘Life is Great’); Generated HTML Overview Hello Word Life is Great

13 13 Application Server 의 HTML 문법 (3) Create a Basic Page PACKAGE basic_htp AS PROCEDURE show; END basic_htp; PACKAGE BODY basic_htp AS PROCEDURE header IS BEGIN htp.htmlOpen; htp.headOpen; htp.title(‘My First HTML Page’); htp.headClose; htp.comment(‘This is a comment’); END header; PROCEDURE body IS BEGIN htp.bodyOpen(cattributes => ‘BGCOLOR=“00FFFF”’); htp.header(1,’Heading Level 1’); htp.paragraph(‘CENTER); htp.print(‘My paragraph’); END body; PROCEDURE footer IS BEGIN htp.address(‘©Oracle Education’); htp.bodyClose; htp.htmlClose; END footer PROCEDURE show IS BEGIN header; body; footer; END show; END basic_htp;

14 14 Application Server 의 HTML 문법 (4) Dynamic HTML Table 을 만들어 DB 의 Data 를 조회 create or replace procedure display_emp is cursor emp_cursor is select e.empno, ename, sal, d.dname from emp e, dept d where e.deptno = d.deptno order by e.empno; begin header(‘ 사원조회 ’); htp.tableOpen(‘BORDER’); htp.tableCaption(‘Employee Table’); htp.tableRowOpen; htp.tableHeader(‘ 사원번호 ’); htp.tableHeader(‘ 사원명 ’); htp.tableHeader(‘ 부서명 ’); htp.tableHeader(‘ 급여 ’); htp.tableRow.Close; for hrec in emp_cursor loop htp.tableRowOpen; htp.tableData(hrec.empno); htp.tableData(hrec.ename); htp.tableData(hrec.dname); htp.tableData(hrec.sal); end loop; htp.tableClose; footer; end;

15 15 Application Server 의 HTML 문법 (5) Web 에서 사원조회 Form 생성 create or replace procedure emp_query (the_dname in varchar2 default NULL, the_ename in varchar2 default NULL) is cursor cu is select * from dept order by deptno; dummy BOOLEAN; begin header(‘ 사원조회 ’);htp.br; htp.centerOpen; if(the_dname is not null) then htp.img(‘/ows-img/ball_red.gif’); htp.bold(the_dname||’ 부서의 사원 현황 ’); htp.img(‘/ows-ing/ball_red.gif’);htp.br; dummy := owa_util.tablePrint(‘emp, dept’, ‘BORDER’, owa_util.html_table, ‘empno, ename, dname, sal’, ‘where emp.deptno = dept.deptno and emp.ename like “’||the_ename||’%” and dept.dname = “’||the_dname||’|’, ‘ 사원번호, 사원명, 부서명, 급여 ’); htp.br;htp.br;htp.hr; end if; htp.formOpen(‘emp_query’); htp.p(‘ 조회할 조건을 넣으세요..’); htp.formSubmit(NULL,’ 조회 ’);htp.br; htp.tableOpen; htp.tableRowOpen; htp.p(‘ ’); htp.p(‘ 사원 이름 : ‘);

16 16 Application Server 의 HTML 문법 (6) htp.formText(‘the_ename’, 10, 15); htp.tableRowClose; htp.tableRowOpen; htp.p(‘ ’); htp.formSelectOpen(‘the_dname’, ‘ 부서 : ‘); for I in cu loop htp.formSelectOption(I.dname); end loop; htp.form.SelectClose; htp.tableRowClose; htp.tableClose;htp.br; htp.formClose; htp.centerClose; footer EXCEPTION WHENOTHER THEN htp.p(SQLERRM); end; 조회

17 17 Application Server 의 HTML 문법 (7) Web 에서 데이터 입력 – 참고 1 Web 에서 데이터 삭제 – 참고 2

18 18 Application Server 의 HTML 문법 (8) OWA_UTIL Package 를 이용 create or replace procedure show_src is begin header(‘ 소스보기 ’); htp.br; owa_util.signature; hpt.br;htp.br; owa_util.signature(‘EMP_QUERY’);htp.br; owa_util.showsource(‘EMP.QUERY’); footer; end; This page was produced by the Oracle Web Agent on March 5, 1999 11:35 AM

19 19 Application Server 의 HTML 문법 (9) Create or replace procedure show_env is v_pathvarchar2(100); v_ipvarchar2(30); begin header(CGI Environment Variables’); htp.br; v_ip := owa_util.get_cgi_env(‘REMOTE_ADDR’); htp.p(‘Your IP Addess is ‘||v_ip); htp.hr; v_path := owa_util.get_cgi_env(‘HTTP_USER_AGENT’); htp.p(‘Your Web Browser is ‘||v_path); htp.hr; owa_util.print_cgi_env; footer; end; Server_name :The server host name server_software :The name and version gateway_interface http_accept : http_referer :The calling URL http_user_agent :The client’s browser

20 20 Application Server 의 HTML 문법 (10) OWA_COOKIE 를 이용 Cookie 설정한다. Create or replace procedure display_emp is v_cookieowa_cookie.cookie; begin owa_util.mime_header(‘text/html’,false); v_cookie := owa_cookie.get(‘counter’); if(v_cookie.num_vals > 0) then owa_cookie.send(‘counter’, v_cookie.vals(1)+ 1, Sysdate); else owa_cookie.send(‘counter,1,Sysdate); end if owa_util.http.header_close; header(‘Cookie’);htp.br; if v_cookie.num_val > 0 then htp.print(‘ 당신은 이 사이트에 ‘||htf.strong(v_cookie.vals(1)+1 ||’ 번째 방문하셨습니다.’); else htp.print(‘This is your First visit here!’); end if;htp.br; footer; end;

21 21 Summary Application Server 는 쉽게 동적인 데이타 베이스 정보를 만들어 준다. –PL/SQL CODE 로부터 HTML 문서를 생성 –PL/SQL 로 직접 TABLE 에 Access – 실행시 PL/SQL cartridges 로 컨트롤


Download ppt "Oracle Application Server 1999. 3. 5 DB Lab. 이재광."

Similar presentations


Ads by Google