Oracle Consulting Oracle Training Oracle Support Development
Home
Catalog
Oracle Books
SQL Server Books
IT Books
Job Interview Books
eBooks
Rampant Horse Books
911 Series
Pedagogue Books

Oracle Software
image
Write for Rampant
Publish with Rampant
Rampant News
Rampant Authors
Rampant Staff
 Phone
 800-766-1884
Oracle News
Oracle Forum
Oracle Tips
Articles by our Authors
Press Releases
SQL Server Books
image
image

Oracle 11g Books

Oracle tuning

Oracle training

Oracle support

Remote Oracle

STATSPACK Viewer

Privacy Policy

 

 
 

oerr on Windows

 
The oerr utility is only available on LINUX & UNIX , but it does not take much code to access the same message file and display the same error messages on a Windows server. To do custom oerr, the actual message file must be ftp’d from a UNIX host to the Windows machine and placed in the same directory as the Java program.

Also see: advanced oerr utility scripts.
 
The Java program below (oerr.java) reads the message file and displays the text associated with the error code:
 
< oerr.java

import java.io.*;
 
public class oerr {
 
static final String badCommand = "Usage: oerr facility error \n" +
"Facility is identified by the prefix string in the error message.\n" +
"For example, if you get ORA-04030, \"ora\" is the facility and \"04030\"\n" +
"is the error. So you should type \"oerr ora 04030\". \n" +
"\n" +
"If you get LCD-111, type \"oerr lcd 111\", and so on.\n";
 
public static void main (String args[]) {
 
if (args.length < 1) {
System.out.println(badCommand);
System.exit(0);
}
 
String fileName = null;
if (args[0].equalsIgnoreCase("ora"))
fileName = "oraus.msg";
else {
System.out.println("No message file available for that facility");
System.exit(0);
}
 
try {
 
FileReader fr = new FileReader( fileName );
BufferedReader br = new BufferedReader(fr);
String lineOfText;
while (!(null==(lineOfText=br.readLine()))) {
if (!lineOfText.startsWith("//")) {
if (lineOfText.startsWith(args[1])) {
System.out.println(lineOfText);
while ((lineOfText=br.readLine()).startsWith("/")) {
System.out.println(lineOfText);
}
}
}
} // while
 
br.close();
fr.close();
}
catch (Exception e) {
System.out.println("Exception occurred: " + e);
}
}
}
 
 
This program was designed to resemble the oerr utility on UNIX as much as possible. It processes facility names, though the ORA facility is the only one used in this program. Other facilities and their message files could easily be added to the program.
 
The Java program reads the message file line by line until it encounters the actual error code. While it does take more time to retrieve an error message located at the end of the file, the message is returned within a second, even when processing large message files.
 
To execute this program would require the following syntax:
 
C:\oracle9i\bin\java oerr ora 00942
 
To make it easier to execute the program and make it resemble oerr even more, the oerr.bat file below can be created to insulate the user from typing the “java” keyword on the command line.
 
< oerr.bat
 
@echo off
java oerr %1 %2
 
Executing the bat file above from the DOS prompt, the command will work exactly as it does in UNIX :
 
c:\oracle11g\bin\oerr zzz 01234

01234, 00000, "You have been a bad PL/SQL program"
// *Cause: No worship of Kernigan & Richie
// *Action: Repent
 

 

 

   

 Copyright © 1996 -2016 by Burleson. All rights reserved.


Oracle® is the registered trademark of Oracle Corporation. SQL Server® is the registered trademark of Microsoft Corporation. 
Many of the designations used by computer vendors to distinguish their products are claimed as Trademarks