1 / 12

PSP

PSP. Oracle Application Server. Configurations. Database Access Descriptor (DAD) Username: scott Password: tiger Connect String: localhost:1521:orc Create a Procedure Go to url: http://localhost/pls/simpledad/<procname>. Example. CREATE OR REPLACE PROCEDURE myhello AS BEGIN

grace-guy
Download Presentation

PSP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PSP Oracle Application Server

  2. Configurations • Database Access Descriptor (DAD) • Username: scott • Password: tiger • Connect String: localhost:1521:orc • Create a Procedure • Go to url: • http://localhost/pls/simpledad/<procname>

  3. Example CREATE OR REPLACE PROCEDURE myhello AS BEGIN htp.print('<HTML> <HEAD> <TITLE>My First Page</TITLE> </HEAD> <BODY BGCOLOR="white"> <H1>Hello, Web!</H1> </BODY> </HTML>'); END;

  4. Example 2 CREATE OR REPLACE PROCEDURE myhello AS BEGIN htp.htmlOpen; htp.headOpen; htp.title('My First Page'); htp.headClose; htp.bodyOpen( cattributes => 'BGCOLOR="white"'); htp.header(1, 'Hello, Web!'); htp.bodyClose; htp.htmlClose; END;

  5. Reference http://otn.oracle.co.kr/docs/oracle78/was3x/was301/cart/carttoc.htm htp and htf packages htp – hypertext procedures Htf – hypertext functions (returns varchar2)

  6. Reuse code Create procedures to reuse code: CREATE OR REPLACE PACKAGE hutil AS PROCEDURE hOpen( p_title IN VARCHAR2 DEFAULT NULL ,p_bgcolor IN VARCHAR2 DEFAULT '"white"' ); PROCEDURE hClose; END;

  7. CREATE OR REPLACE PACKAGE BODY hutil AS PROCEDURE hOpen( p_title in varchar2 ,p_bgcolor in varchar2 ) IS BEGIN htp.htmlOpen; htp.headOpen; htp.title( p_title ); htp.headClose; htp.bodyOpen( cattributes=> 'BGCOLOR=' || p_bgcolor ); END; PROCEDURE hClose IS BEGIN htp.bodyClose; htp.htmlClose; END; END;

  8. Use hutil CREATE OR REPLACE PROCEDURE myhello3 AS BEGIN hutil.hOpen('My First Page'); htp.header(1, 'Hello, Web!'); hutil.hClose; END;

  9. CREATE OR REPLACE PROCEDURE show_max_sal as maxSal scott.emp.sal%TYPE; cursor salCur IS SELECT MAX(sal) FROM scott.emp; noEmp exception; BEGIN hutil.hOpen( 'Salary Max'); OPEN salCur; FETCH salCur INTO maxSal; if salCur%NOTFOUND then raise noEmp; end if; CLOSE salCur; htp.print('The highest salary is: ' || maxSal); hutil.hClose; EXCEPTION WHEN noEmp THEN htp.print('Warning: There are no employees.'); hutil.hClose; END; Display database data

  10. Table CREATE OR REPLACE PROCEDURE empPrint AS BEGIN hutil.hOpen('Employees'); htp.tableOpen('BORDER'); htp.tableRowOpen; htp.tableHeader('Emp#'); htp.tableHeader('Name'); htp.tableHeader('Sal'); htp.tableRowClose; FOR theEmp IN (SELECT empno, ename, sal FROM scott.emp ORDER BY empno) LOOP htp.tableRowOpen; htp.tableData( theEmp.empno ); htp.tableData( theEmp.ename ); htp.tableData( theEmp.sal ); htp.tableRowClose; END LOOP; htp.tableClose; hutil.hClose; END;

  11. Dynamic Result CREATE OR REPLACE PROCEDURE empPrint2( p_deptno IN VARCHAR2 DEFAULT '%' ) AS BEGIN hutil.hOpen('Employees'); htp.tableOpen('BORDER'); FOR theEmp IN (SELECT empno, ename, sal FROM scott.emp WHERE deptno like p_deptno ORDER BY empno ) LOOP htp.tableRowOpen; htp.tableData( theEmp.empno ); htp.tableData(theEmp.ename ); htp.tableData(theEmp.sal ); htp.tableRowClose; END LOOP; htp.tableClose; hutil.hClose; END;

  12. Create the input form • To send parameter use the address: • http://url/empprint2?p_deptno=30 • Html form: <form action="empprint2" method=get> <input type=text name="p_deptno"> <input type=submit value="find"> </form>

More Related