Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Looking for "integrating sqlplus/ksh" resources

Posted on 2003-02-21
3
Medium Priority
?
707 Views
Last Modified: 2013-12-26
Can someone direct me to some good resources that have examples of integrating sqlplus execution inside a Korn Shell script.
I need to:
- Pass sqlplus success/fail status back to the ksh.
- Trap sql errors in my ksh application and perform "ksh" conditional logic on these errors.
- Toggle back and forth between ksh execution and sqlplus.
- Run and capture stored procedure results (hopefully same as std SQL query).

I'm a Windows programmer by trade so much of this is "Greek" to me.

Operating system is (I believe...)HP-UX V.5.1 1885 alpha
DB is Oracle 8i

Thanks for your help.
0
Comment
Question by:GeekMan
  • 2
3 Comments
 
LVL 2

Expert Comment

by:ellesd
ID: 7994999
If you are running sqlplus from the script, you will need to test the $? variable for success or failure (0 is success and non-zero is failure:

if [ "$?" -eq 0 ]
then
  SUCCESS CODE
else
  FAILURE CODE
fi

You need a space after the [ and before the ].

If you are trying to execute certain code based on certain errors returned, you will put a case statement in the FAILURE CODE section:

case $?
in
  1)
     cmd1
     cmd2
     ;;
  2)
     cmd3
     cmd4
     ;;
  *)
     default code
     ;;
esac

Obviously you put your desired error codes in place of the 1, 2, and so on (list as many as you are checking).  Replace the cmd1, cmd2, ... with your desired commands.
The two semicolons are required to end execution of that particular set of commands.  The *) case is to catch any value you did not account for and run whatever commands you want for that situation.

Elaborate on the rest and I should be able to assist some more.
0
 
LVL 2

Accepted Solution

by:
ellesd earned 200 total points
ID: 7995006
Oh, forgot to mention that you can get alot of the info you need by reading the man page on ksh:

man ksh

Run from unix prompt obviously.
0
 

Author Comment

by:GeekMan
ID: 8063978
Thanks for your help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question