chap17_2.html
来自「Oracle资料大集合」· HTML 代码 · 共 427 行 · 第 1/2 页
HTML
427 行
</tr><tr><td colspan="2"><img src="../../../images/dotclear.gif" width=6 height=12 alt="" border="0"></td></tr><tr><td><img src="../../../images/arrow.gif" width=10 height=17 alt="" border="0"></td><td><a href="http://www.itlibrary.com/reference/dir.hardware1.html"><font face="verdana,helvetica" size="1" color="000000"><b>Hardware</b></font></td></tr><tr><td colspan="2"><img src="../../../images/dotclear.gif" width=6 height=12 alt="" border="0"></td></tr><tr><td><img src="../../../images/arrow.gif" width=10 height=17 alt="" border="0"></td><td><a href="http://www.itlibrary.com/reference/dir.funandgames1.html"><font face="verdana,helvetica" size="1" color="000000"><b>Fun & Games</b></font></td></tr></table><!-- <IMG SRC="/images/leftnav.gif" WIDTH=111 HEIGHT=404 ALT="nav" border="0" ISMAP USEMAP="#leftnav"> --><p><a href="http://www.earthweb.com/jobs/" target=new><IMG SRC="../../../images/dice-105x30.gif" WIDTH=105 HEIGHT=30 ALT="EarthWeb Direct" border="0"></a><a href="http://www.earthwebdirect.com/" target=new><IMG SRC="../../../images/earthwebdirect.gif" WIDTH=105 HEIGHT=30 ALT="EarthWeb Direct" border="0"></a><a href="http://www.fatbrain.com/home.html?from=UUX592" target=new><IMG SRC="../../../images/fatbrain.gif" WIDTH=105 HEIGHT=30 ALT="Fatbrain" border="0"></a><a href="http://auctions.earthweb.com" target=new><IMG SRC="../../../images/auctions_105x30.gif" WIDTH=105 HEIGHT=30 ALT="Auctions" border="0"></a><a href="http://www.supportsource.com" target=new><IMG SRC="../../../images/ss2000sneak2.gif" WIDTH=105 HEIGHT=30 ALT="Support Source Answers" border="0"></a><P><b><font face="verdana,helvetica" size="2">EarthWeb sites</FONT></b><br> <FONT SIZE="1"> <a href="http://www.crossnodes.com"><font face="verdana,helvetica" size="1" color="000000">Crossnodes</font></a><br> <a href="http://www.datamation.com"><font face="verdana,helvetica" size="1" color="000000">Datamation</font></a><br> <a href="http://www.developer.com"><font face="verdana,helvetica" size="1" color="000000">Developer.com</FONT></A><br> <a href="http://www.dice.com"><font face="verdana,helvetica" size="1" color="000000">DICE</font></a><br> <a href="http://www.earthweb.com"><font face="verdana,helvetica" size="1" color="000000">EarthWeb.com</font></a><br> <a href="http://www.earthwebdirect.com"><font face="verdana,helvetica" size="1" color="000000">EarthWeb Direct</font></a><br> <a href="http://www.erphub.com"><font face="verdana,helvetica" size="1" color="000000">ERP Hub</font></a><br> <a href="http://www.gamelan.com"><font face="verdana,helvetica" size="1" color="000000">Gamelan</font></a><br> <a href="http://www.gocertify.com"><font face="verdana,helvetica" size="1" color="000000">GoCertify.com</font></a><br> <a href="http://www.htmlgoodies.com"><font face="verdana,helvetica" size="1" color="000000">HTMLGoodies</font></a><br> <a href="http://www.intranetjournal.com"><font face="verdana,helvetica" size="1" color="000000">Intranet Journal</font></a><br> <a href="http://www.itknowledge.com"><font face="verdana,helvetica" size="1" color="000000">IT Knowledge</font></a><br> <a href="http://www.itlibrary.com"><font face="verdana,helvetica" size="1" color="000000">IT Library</font></a><br> <a href="http://www.javagoodies.com"><font face="verdana,helvetica" size="1" color="000000">JavaGoodies</font></a><br> <a href="http://www.jars.com"><font face="verdana,helvetica" size="1" color="000000">JARS</font></a><br> <a href="http://www.javascripts.com"><font face="verdana,helvetica" size="1" color="000000">JavaScripts.com</font></a><br> <a href="http://www.opensourceit.com"><font face="verdana,helvetica" size="1" color="000000">open source IT</font></a><br> <a href="http://www.roadcoders.com"><font face="verdana,helvetica" size="1" color="000000">RoadCoders</font></a><br> <a href="http://www.Y2Kinfo.com"><font face="verdana,helvetica" size="1" color="000000">Y2K Info</font></a></FONT></td><!--End Left Navigation column --><!-- spacer column --><TD width="40"><img src="../../../images/dotclear.gif" WIDTH="40" HEIGHT="1" border=0></TD><!--Begin Content Column --><TD VALIGN="TOP" width="500"><P><blockquote><p><b><font size="+1">17.2 How do I匯eturn the results of a query to a web document?</font></b><p><B>Problem</B><p>I want to use Oracle web technology to display query results to users. By displaying the results of database queries within web documents, I can provide an easy way to generate reports and analysis information to our users. Many of the people who want this type of information do not need large applications and already have a web browser. How do I return the results of a query to a web page?<p><B>Technique</B><p>A web document can be generated dynamically by stored procedures you create. The results of functions, PL/SQL operations, and queries can be presented within web documents. The stored procedure is invoked through the PL/SQL Agent. The PL/SQL Agent executes the corresponding stored procedure and returns the resulting HTML to the browser. In the stored procedure, the results of the query executed is formatted into HTML by using functions and procedures in the HTP package to display the web document in the browser. The HTP package contains a set of procedures that print text and HTML tags to the browser. The HTF package contains functions that correspond to each of the HTP procedures. The functions return VARCHAR2 results that can be used within the PL/SQL code. The PL/SQL Web Toolkit makes it easy to display results of queries within web documents.<p><B>Steps</B><p><B>1.</B> Run SQL*Plus and connect as the WAITE account. CHP17_1.SQL, shown in <A HREF="image/17oht06.gif" TARGET="_blank">Figure 17.6</A>, creates the sample table used in this How-To.<p>Run the file to create the sample table and data.<p><code><b>SQL> START CHP17_1<p>Table created.<p>1 row created.<p>1 row created.<p>1 row created.<p>1 row created.</b></code><p><B>2.</B> Run the CHP17_2.SQL file in SQL*Plus, as shown in <A HREF="image/17oht07.gif" TARGET="_blank">Figure 17.7</A>. The procedure contained in the file queries the DEPT17 table created in Step 1 and displays the results of the query using the PL/SQL Web Toolkit packages.<p>Line 1 presents the keywords required to create a stored procedure and names the procedure. The cursor declared in lines 2 through 7 declares a cursor that is executed within the procedure body, which lines 8 through 21 contain. The HTP.HTMLOPEN procedure in line 9 and the HTP.HTMLCLOSE procedure in line 20 begin and end the document, respectively. Line 10 uses the HTP.HTITLE procedure to create the title tags,<TITLE> and </TITLE>, and heading tags, <H1> and </H1>, establishing a title and a heading for the document. The parameter passed to the procedure is used as both the title and the heading. Table 17.1 contains the HTP package procedures in the PL/SQL Web Toolkit used for formatting heading and structure related tags. <p>Table 17.1 Heading and structure related procedures<p><table cellpadding=3 cellspacing=3 bgcolor="cdcdcd" border=0></TABLE><TR><td>Procedure</td><td>Description</td></TR><TR><td>htp.htmlOpen</td><td>Prints the <HTML> tag indicating the beginning of document.</td></TR><td>htp.htmlClose</td><td>Prints the </HTML> tag indicating the end of document.</td><TR><td>htp.headOpen</td><td>Prints the <HEAD> tag indicating the beginning of document head.</td></TR><TR><td>htp.headClose</td><td></TD>Prints the </HEAD> tag indicating the end of document head.</td></TR><TR><td>htp.bodyOpen<td>Prints the <BODY> tag indicating the beginning of document body.</td></TR><TR><td>htp.bodyClose</TD><td>Prints the </BODY> tag indicating the end of document body.</td></TR><TR><td>htp.title</td><td>Prints the title specified with the <TITLE> and </TITLE> tags.</td></TR><TR><td>htp.htitle</td><td>Creates both title tags and heading tags.</td></TR><tr><td>htp.base</td><td>Prints a tag that records the URL of the current document.</td></tr><TR><td>htp.meta</td><td>Prints a tag that embeds document meta-information.</td></TR></table><p>Lines 14 and 17 begin and end an unordered list by using the HTP.ULISTOPEN and HTP.ULISTCLOSE procedures. Table 17.2 shows the procedures related to lists in the HTP package.<p><table cellpadding=3 cellspacing=3 border=0 bgcolor="cdcdcd"><TR><td>Procedure</td><td>Description</td></TR><TR><td>htp.listHeader</td><td>Creates a header for any type of list.</td></TR><TR><td>htp.listItem</td><td>Generates a list item for an ordered or unordered list.</td></TR><TR><td>htp.ulistOpen</td><td>Opens an unordered list.</td></TR><TR><td>htp.ulistClose</td><td>Closes an unordered list.</td></TR><TR><td>htp.olistOpen</td><td>Opens an ordered list.</td></TR><TR><td>htp.olistClose</td><td>Closes an ordered list.</td></TR><TR><td>htp.dlistOpen</td><td>Opens a definition list.</td></TR><TR><td>htp.dlistClose</td><td>Closes a definition list.</td></TR><TR><td>htp.dlistDef</td><td>Creates a definition in a definition list.</td></TR><TR><td>htp.dlistTerm</td><td>Creates a term in a definition list.</td></TR><TR><td>htp.menulistOpen</td><td>Creates a list more compact than an unordered list.</td></TR><TR><td>htp.menulistClose</td><td>Closes the menu list.</td></TR><TR><td>htp.dirlistOpen</td><td>Creates a directory list.</td></TR><TR><td>htp.dirlistClose</td><td>Closes a directory list.</td></TR></TABLE><p> Rows fetched from the cursor are formatted and displayed within the document by the FOR loop in lines 15 through 18. Column values of each record returned by the query are printed to the document using the HTP.PRINT procedure. The print procedures in the HTP package needed to generate dynamic web content are listed in Table 17.3.<p>Table 17.3 Print procedures<p><table cellpadding=3 cellspacing=3 border=0 bgcolor="cdcdcd"><TR><td>Procedure</td><td>Description</td></TR><TR><td>htp.print</td><td>Prints a text string to the browser.</td></TR><TR><td>htp.p</td><td>Same as HTP.PRINT.</td></TR><TR><td>htp.prn</td><td>Same as HTP.PRINT but does not put a new line at the end of the string.</td></TR><TR><td>htp.prints</td><td>Prints a text string to the browser and replaces all occurrences of <, >,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?