Exforsys.com
 
Home Tutorials PHP Oracle
 

Taking Advantage of Standard Internet Protocols

 

Handling Transactions

Page 2 of 2


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:


Sample Code
  1. rslt:=DBMS_XDB.createFolder('/public/xmlusr/emps/303')
  2. rslt:=DBMS_XDB.createResource('/public/xmlusr/emps/303/emp303.xml',
  3. xmldoc)
  4. COMMIT
  5.  
Copyright exforsys.com


The above PL/SQL code is transactional. If an error occurs during the execution of the createFolder function, 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:


Sample Code
  1. $login = ftp_login($ftpcon, $db_user, $db_pswd)
  2. ftp_chdir($ftpcon, '/public/xmlusr/emps')
  3. ftp_mkdir($ftpcon, '303')
  4. ftp_chdir($ftpcon, '/public/xmlusr/emps/303')
  5. ftp_fput($ftpcon, 'emp303.xml', $xmldoc, FTP_ASCII)
  6. ftp_close($ftpcon)
Copyright exforsys.com



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




First Page: Taking Advantage of Standard Internet Protocols


Read Next: Querying Data with Oracle XQuery



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape