KSH to execute stored procs/ctrl files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KSH to execute stored procs/ctrl files
# 1  
Old 10-24-2010
Question KSH to execute stored procs/ctrl files

I am needing to call sqlplus and sqlldr in the same korn shell script. Below are the steps that I need to accomplish. I am new to Oracle shell scripting so an example would be great.
  • CBOB_LOAD.KSH - script name
  • Calls Oracle stored procedure sp_CBOB_CLEAR_LN_STAGING (SERVER: TESTSVR100)
  • Calls SQL*LOADER script AIMS_LOAD_LOAN.CTL (SERVER: TESTSVR100)
  • Calls Oracle stored procedure sp_CBOB_LOAD_LN (SERVER: TESTSVR100)
  • Run a query to determine row counts of TBL1 & TBL2 tables - Send results via email to the me@work.com in Outlook
I have this pseudo code that I just threw out there of how I would like it to go. I know the code below is wrong but hopefully it is understandable of what I'm trying to accomplish.
Code:
!# /usr/bin/ksh

sqlplus -s user/passwd@TESTSVR100<<END
exec sp_CBOB_CLEAR_LN_STAGING;

sqlldr user/pass@TESTSVR100<<END
exec AIMS_LOAD_LOAN.CTL;

sqlplus -s user/passwd@TESTSVR100<<END
exec sp_CBOB_LOAD_LN;
EOF

if [ $? -eq 0 ]
then
 sqlplus -s user/passwd@TESTSVR100<<END
   exec SELECT COUNT(*) FROM TBL1
   exec SELECT COUNT(*) FROM TBL2
   ---Send results of the TBL1 and TBL2 counts via email
   ---in this format. XXX,XXX records loaded to TBL1
   ---XXX,XXX records loaded to TBL2
else
 ---Send email with "Results Failed"
fi


Last edited by Scott; 10-24-2010 at 03:18 PM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

--killing backround Procs spawned from the parent script with Ctrl+C trap

Hello: Am trying to understand why the method #2 works but method #1 does not. For both methods, sending CTRL+C should kill both the Parent script & all of the spanwd background procs. Method #1: ========================== #!/bin/sh ctrl_c() { echo "** Trapped CTRL-C" ... (3 Replies)
Discussion started by: gilgamesh
3 Replies

2. Shell Programming and Scripting

Unable to execute Stored Procedure from CRON

Hi, I am very new to this environment - I hope this is the right platform to discuss my issue: I created a CRON job to run a Stored Procedure from our database - Sybase. Within the Stored Procedure there is a TRUNCATE table and CREATE table function. the CRON job fails to run with... (2 Replies)
Discussion started by: pizzazzz
2 Replies

3. Shell Programming and Scripting

Execute stored procedure through script in sybase database and store the output in a .csv file

Hi, I have a sybase stored procedure which takes two input parameters (start_date and end_date) and when it get executed, it gives few records as an output. I want to write a unix script (ksh) which login to the sybase database, then execute this stored procedure (takes the input parameter as... (8 Replies)
Discussion started by: amit.mathur08
8 Replies

4. Shell Programming and Scripting

execute command stored in a string

Hi, Here's the problem I am facing. This is just an example: list_files.ksh ------------ dir=$1 match=$2 var="ls $dir | grep $match" files=`"$var"` I get the below error on executing the above script: ./list_files.ksh: ls /home/my_files | grep xml: not found I know I... (2 Replies)
Discussion started by: dips_ag
2 Replies

5. Shell Programming and Scripting

How to execute the stored procedure from shell script

How to execute the stored procedure from shell script and is there any possibility to print the dbms output in a log file. (2 Replies)
Discussion started by: dineshmurs
2 Replies

6. Shell Programming and Scripting

calling a PL/SQL stored procedure from KSH

Hi I have a stored procedure which should be called from KSH. Could ayone please help me with this. Thanks (1 Reply)
Discussion started by: BlAhEr
1 Replies

7. Shell Programming and Scripting

how to enable Ctrl + C in ksh

hi there , server is AIX 5.3 , login shell is ksh , stty -a display as following #stty -a speed 9600 baud; 21 rows; 80 columns eucw 1:1:0:0, scrw 1:1:0:0: intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^@ eol2 = ^@; start = ^Q; stop = ^S; susp = ^Z; dsusp = ^Y; reprint = ^R... (0 Replies)
Discussion started by: dradhzn
0 Replies

8. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies

9. Shell Programming and Scripting

Execute an Oracle stored procedure from a shell scrip

Here is a snippet of my code: if then echo "\n Deleting all reports older than 24 hours. \n" >> $logfile ls -l $FileName >> $logfile ... (1 Reply)
Discussion started by: mh53j_fe
1 Replies

10. UNIX for Dummies Questions & Answers

Executing Oracle Stored Procs from Korn Shell

Can someone tell me how to execute an Oracle Stored Procedure from a Korn Shell Script. Previously, I'm able to execute standard sql using the following:- The_Output=`sqlplus................. << EOF select count(*) from abc / ... (3 Replies)
Discussion started by: Vinny_Mitchell
3 Replies
Login or Register to Ask a Question