Oracle8i Application Developer's Guide - XML
Release 3 (8.1.7)

Part Number A86030-01

Library

Product

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

Using XML-SQL Utility (XSU), 13 of 26


Raising No Rows Exception

When there are no rows to process the utility simply returns a null string. But it might be desirable to get an exception everytime there are no more rows present, so that the application can process this through exception handlers. When the setRaiseNoRowsException() is set, then whenever there are no rows to generate for the output the utility raises a oracle.xml.sql.OracleXMLSQLNoRowsException. This is a run time exception and need not be caught unless needed. The following code extends the previous examples to use the Exception instead of checking for null strings.

XSU Example 6: No Rows Exception (Java)

public class pageTest { 
    .... // rest of the class definitions....

   public void main(String[] argv)
   {
     pageTest test = new pageTest("select * from emp");

     test.query.setRaiseNoRowsException(true); // ask it to generate 
exceptions
     try
     {
        while(true)
         System.out.println(test.nextPage());
     } 
     catch(oracle.xml.sql.OracleXMLNoRowsException)
     {
       System.out.println(" END OF OUTPUT ");  
       test.close();
     }
   }
}

Note how the condition to check the termination changed from checking for the result to be null to an exception handler.


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index