The return (exit) code of ociuldr text unload utility

Links: http://www.dbatools.net/mytools/ociuldr_exit_code.html

    About half years ago, someone told me to add this, because he want to get more control of ociuldr utility in his shell script. I was afraid of change any code at that time, so just left him along. Today I made some change to the source code, the return or exit code is implemented as following :

0 = Successful
1 = Cannot login to database
2 = Cannot create cursor handle
3 = Cannot prepare SQL statement
4 = Cannot execute SQL query
5 = Cannot get the metadata of the result set
6 = Cannot create output file
7 = Oracle error found when fetching rows, such as ORA-01555 etc.

    Let's begin verification. When we cannot connect to database :

bash-2.03$ ./ociuldr.bin user=anysql/anysq1@test  query="select * from tab"
Cannot connect as anysql/anysq1@s8i.
Connection failed.  Exiting...
bash-2.03$ echo $?
1

    When wrong SQL is provided :

bash-2.03$ ./ociuldr.bin user=anysql/anysql@test  query="select * from tab1"
ORA-00942: table or view does not exist
bash-2.03$ echo $?
3

    When no permission of creating text file.

bash-2.03$ ./ociuldr.bin user=anysql/anysql@test  query="select * from tab" file=/test.txt
   15500 bytes allocated for column TNAME (1)
    4000 bytes allocated for column TABTYPE (2)
   20500 bytes allocated for column CLUSTERID (3)

ERROR -- Cannot write to file : /test.txt
bash-2.03$ echo $?
6

    Hope he can read this article, sorry for the later.

Post a comment

« Previous | Main | Next »

Powered by
Movable Type 3.36