The following articles mainly introduce how to correctly apply the Oracle component to implement a dynamic Web database, this includes how to use Oracle WebServer to build Web database applications and actual PL/SQL applications, and using WebServer and PL/SQL to develop Oracle components to implement dynamic Web instances.
1. Use Oracle WebServer to build Web database applications
Oracle 8 Server is a complete information management environment. It is a storage space for a large amount of data and provides users with quick access to the data. It supports the C/S structure for distributed processing and Web computing. WebServer, one of its server options, provides powerful functions for Web database applications.
Generally, Web database applications can provide CGI, APIs, and other middleware on the WebServer end to connect to WebServer and DB Server, or allow users to download and run related applications to the client through a Web browser, access the database directly on the client, such as Java Applet, Active X, and Plug-in. This article describes how to use PL/SQL provided by Oracle 8 and its powerful built-in package to write programs for Dynamic Web applications.
It is developed using middleware. Middleware manages communication between WebServer and DBServer and provides application services. It can directly call external programs or script code to access the database. Therefore, it can provide dynamic HTML pages related to the database, or execute the user query, format the query result into an HTML page, and then return it to the user's browser through WebServer. The general structure is as follows:
Web browsers → Internet → Web Server → CGI/API → Oracle DB Server
2. PL/SQL
Oracle supports a process processing language PL/SQL starting with version 6 and uses it as the standard programming language for all Oracle tools, so that all the process Oracle components can be implemented in Oracle Server products. PL/SQL can be used to implement the following important functions:
Stored procedures, that is, programs or code segments stored in Oracle databases) and perform specific important work for your organization;
Database triggers, that is, the Code stored in the database, can be triggered by events generated by the application;
Package, that is, the code that combines multiple processes as a single program unit is stored in the database.
The built-in packages are pre-generated and stored in the database, and can be called in PL/SQL code blocks to pass parameters as needed. It can directly output the results to the terminal window, read and write data directly from the operating system file, and execute dynamic SQL and other functions. Commonly used such as HTP, HTF, OWA-UTIL, etc. The following uses an instance of dynamic online score query to describe its application in dynamic Web.
3. Use WebServer and PL/SQL to develop Oracle components for Dynamic Web instances
The current score library of one candidate must provide the score query function online. First, you can use the HTP package to query the corresponding information in the database based on the student ID you entered and return a webpage. The Code is as follows:
- [pre]Create or replace procedure score_into_webpage (code_in in number)
As cursor score_cursor is select code,name,score from student where code = code_in;
- Begin Htp.htmlopen;
- Htp.headopen; Htp.title ('Student's score information');
- Htp.headclose; Htp.bodyopen (cattributes=>'bgcolor = "#80800"'); Htp.tableopen(border');
- Htp.tablecaption ('Score Information','center');
- Htp.tablerowopen; Htp.tableheader (' Student Code');
- Htp.tableheader (' Student Name');
- Htp.tableheader (' Student Score');
The page title, title, header, and other information are displayed.
The same Htp. tablerowclose; For score_rec in score_cur Loop uses the cursor's For Loop to generate a data row For the cursor in the webpage.
- htp.tablerowopen; htp.tabledata (score_rec.code); htp.tabledata (score_rec.name);
- htp.tabledata (score_rec.score);
- htp.tablerowclose; Endloop;
- Htp.tableclose; Htp.bodyclose;
- Htp.htmlclose; End;[/pre]
Through the above Code, we have a basic method to dynamically generate a webpage using the data in the database. Below we will create a simple form. In the form, call the above program and accept the user-entered candidate number, so that the client dynamically displays the information queried from the database to the user.
- [pre]Create or replace procedure ScoreForm As Begin Htp.headopen;
- Htp.title ('Code Entry Form');
- Htp.headclose; Htp.bodyopen; Htp.header (2,'Score Information Code Form');
- Htp.p (' ');
- Htp.formopen ('Score_into_webpage',cmethod=>'GET');
Open the ScoreForm form.
By default, score_pai_webpage PL/SQL is called using the GET method. The GET method shows the passed parameters in the URL.
- Htp.tableopen ('border'); Htp.tablerowopen; Htp.tabledata ('Enter Student Code');
Htp.tabledata (htf.formtext ('code_in',5,5));
Prompt the user to enter the examination number in a text box. The text box name must be the same as the input parameters in the call process.
- Htp.tablerowclose;
- Htp.tablerowopen; Htp.tablerowclose; Htp.tablerowopen;
- Htp.tabledata (htf.formSubmit); Htp.tabledata (htf.formReset);
- Htp.tablerowclose; Htp.formclose; Htp.bodyclose; Htp.htmlclose; End;[/pre]
The HTML generated after the client is called in the above process displays a dynamic form that accepts the user's input test number, and then passes it to the called process score_pai_webpage to query the required data in the Oracle DBServer, then, the dynamically generated HTML is displayed in the Oracle component in a dynamic Web browser.
4. Conclusion
As a large database server, Oracle provides a comprehensive platform for network-oriented development tools, application servers, and database servers. This article uses its standard PL/SQL and built-in package and WebServer to discuss the development and application of basic dynamic Web.