?
Solved

Looking for "integrating sqlplus/ksh" resources

Posted on 2003-02-21
3
Medium Priority
?
700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

771 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