alt
Advertisement
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow PHP Oracle arrow Taking Advantage of Standard Internet Protocols
Site Search


Taking Advantage of Standard Internet Protocols
Article Index
Taking Advantage of Standard Internet Protocols
Handling Transactions

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:

  1. rslt:=DBMS_XDB.createFolder('/public/xmlusr/emps/303');
  2. rslt:=DBMS_XDB.createResource('/public/xmlusr/emps/303/emp303.xml',
  3. xmldoc);
  4. COMMIT;
 

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:

  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);
 

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


Trackback(0)
Comments (0)add comment

Write comment

busy

 
< Prev   Next >
Sponsored Links
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape