tailieunhanh - Building Oracle XML Applications phần 6

Bạn có thể thực hiện các thủ tục từ SQL * Plus dòng lệnh bằng cách sử dụng lệnh EXEC như sau: EXEC QuotesForStocksInPortfolio (101) Sau khi thực hiện thành công, bạn có thể xem nội dung của bộ đệm trang web bằng cách phát hành: EXEC Nếu trước đó bạn đã ban hành serveroutput SET ON từ SQL * Plus, | You can execute the procedure from the SQL Plus command line using the EXEC command as follows EXEC QuotesForStocksInPortfolio 101 After successful execution you can see the resulting contents of the web page buffer by issuing EXEC If you have previously issued SET SERVEROUTPUT ON from SQL Plus you will see the contents of the page buffer in your SQL Plus command console. After requesting the page buffer the OWA routines flush the buffer. If you are using one of the web servers listed earlier on a computer named yourserver and you have properly registered a virtual path location named yourpath to point to the database schema where you created the previous PL SQL procedure you can request the page through a web browser or any program capable of making an HTTP request using the URL http yourserver yourpath QuotesForStocksInPortfolio id 101 Formatting Database Data in XML Using PL SQL The process of generating dynamic XML documents in PL SQL based on query results is identical to the procedure used for generating HTML 1. Identify the set of data to publish in XML by executing one or more SQL queries. 2. Loop over the resulting data. 3. Output the data surrounded by appropriate XML tags. Returning an XML stock quote datagram When you want to format database query results in XML instead of HTML the programming techniques remain the same only the tags around the data change. By making slight modifications to Example we can generate dynamic XML datagrams filled with stock quotes in no time. Studying Example you ll notice a few obvious changes We re explicitly setting the MIME type of the returned document to text xml using the MIME_HEADER routine in the built-in OWA_UTIL package. We re outputting an XML declaration instead of an HTML tag as the very first text in the page. The tags used to mark up the data have meaningful element names that reflect the structure of the query result s information unlike the fixed set of HTML .