spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / programming/php / xml-enabled-applications4

[previous] [next]

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


XML-Enabled Applications - Part 4

Taking Advantage of Standard Internet Protocols

As mentioned, Oracle XML DB provides native support for standard internet protocols, such as HTTP(S), WebDAV, and FTP. Continuing with the preceding sample, you might, for example, upload another employee XML document into the XML repository with one of the above protocols, say, FTP.

[ Starting with Oracle Database 10g Release 2, FTP is disabled by default, for security reasons. This is achieved by setting the FTP port to 0. To enable FTP, you must manually set the FTP port number to an appropriate value, such as 2100, which is the default value in Oracle Database releases before 10g Release 2. Changing the FTP port to an appropriate value can be easily done with the help of Oracle Enterprise Manager, a graphical tool supplied with Oracle Database. For more information on Oracle Enterprise Manager, refer to Oracle documentation: chapter Getting Started with Oracle Enterprise Manager in the Oracle Database 2 Day DBA manual. ]

The uploadXML.php script shown below provides a simple example of how you might upload an XML document into the XML repository through FTP protocol.

In the above script, you start by setting up the parameters required to connect to the FTP server running on the database server.

By including the value of the employee's id attribute in the name of the XML file to be uploaded into the XML repository, you ensure the uniqueness of file names within the repository folder that contains employee XML documents in single files.

Then, you create a temp file and write XML content in it. Then, you connect to the Oracle FTP server and upload the file into the XML repository.

After the uploadXML.php script is executed, to make sure that the employee XML document has been successfully uploaded into the XML repository, you might issue the following query from SQL*Plus:

If everything is OK, this query should output the employee XML document uploaded by the uploadXML.php script:

So, after the uploadXML.php script is executed, the XML document inserted by the script becomes permanent immediately.

Handling Transactions

As you can see from the preceding example, changes made through internet protocols to repository resources become permanent once a single operation on a resource has been completed.

In contrast, all SQL and PL/SQL operations that you perform on the XML data stored in Oracle XML DB are transactional, irrespective of whether you're using XMLType storage or the XML repository. This allows you to combine SQL and PL/SQL statements operating on XML data within a logical unit of work and explicitly commit the transaction or roll it back if necessary.

Suppose you want to create a folder in the XML repository and then upload an XML document in it. The following code fragment shows how this can be done in PL/SQL:

The above PL/SQL code is transactional. If an error occurs during the execution of the createFolderfunction, then the results of execution of createFolder are discarded automatically.

On the other hand, when performing the same operations through FTP protocol, failure to create the resource doesn't affect the results of preceding operation. So, the following fragment of PHP code is not transactional:

[ Chapter 4 Transactions, presented earlier in this book, explains in detail how to use transactions in PHP/Oracle applications. ]

home / programming / programming/php / xml-enabled-applications4

[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

URL: