Getting detailed error from sql script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting detailed error from sql script
# 1  
Old 03-22-2016
Getting detailed error from sql script

Hello,

I have a main.sql file which runs around 5-6 .sql files and each .sql file is spooling it in separate text file.

In my shell script I am appending main.sql to one of my log file but I am not able to get detailed error if anything fails from those 5-6 .sql files. Those errors are going to corresponding text file. How Can I get the detail error in my .log file??
Shell script code is as follows:
Code:
sqlplus -s db/abc@hostname /main.sql >> /sample.log

main.sql is as follows:
Code:
WHENEVER SQLERROR EXIT.SQLCODE
PROMPT 1.sql is running
@/1.sql
set termout on
PROMPT 2.sql is running
@2.sql
set termout on

# 2  
Old 03-22-2016
Try redirecting stderr to stdout:
Code:
sqlplus .... >> logfile 2>&1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script with sql script error

Hi All when I execute from psql prompt, I get the result, when I try to automate using a shell script, the query is not working # `/usr/bin/psql -U postgres -d coba1 -c "select name from users where "Date" > current_date - 30;"` ERROR: column "Date" does not exist LINE 1: select... (2 Replies)
Discussion started by: srilinux09
2 Replies

2. UNIX for Advanced & Expert Users

Exit when sql script give error

Hi Guys, I am calling a SQL script which runs under while loop, i need to exit the while loop if i get error in sql script which is called while do sqlplus -s user/pass@db @test.sql id$i done test.sql whenever sqlerror exit; alter table t1 add &1 number; I need to come out of... (2 Replies)
Discussion started by: rohit_shinez
2 Replies

3. Shell Programming and Scripting

How to catch sql error in script?

Hi Gurus, I have a script which send sql query to oracle db and return value to my script. dummy code like below: sqlplus -s user/${PASSWD}@${ORACLE_SID} @${DIR}/query.sql > outputfile using above code, when query has error, it send error to same out put file and exit code is 0, is... (6 Replies)
Discussion started by: ken6503
6 Replies

4. Shell Programming and Scripting

How to get rid off Password expiry error message when connecting to sql in script?

I am connecting to sql databases through shell script. Databases that i am connecting will need password change every 60 days. This is according to our security policy and cannot be changed. But this is creating problem when connecting to Databases through shell script . To connect to oracle DB we... (2 Replies)
Discussion started by: pallvi_mahajan
2 Replies

5. Shell Programming and Scripting

Calling SQL script from ksh job and send mail on some error.

Hi, I am trying to call sql script from ksh job with parameters.The parameters passed from ksh job will be used in SELECT query in sql file to SPOOL the data in extract file.My questions are: 1) How to call a sql script from ksh job with parameters? 2) How to use the parameter in sql file to... (1 Reply)
Discussion started by: anil029
1 Replies

6. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

7. UNIX for Dummies Questions & Answers

Execute PL/SQL function from Unix script (.sql file)

Hi guys, I am new on here, I have a function in oracle that returns a specific value: create or replace PACKAGE BODY "CTC_ASDGET_SCHED" AS FUNCTION FN_ASDSCHEDULE_GET RETURN VARCHAR2 AS BEGIN DECLARE ASDSchedule varchar2(6); ASDComplete... (1 Reply)
Discussion started by: reptile
1 Replies

8. Shell Programming and Scripting

error connecting sql through a shell script

Hi I am getting this error while connecting to sql through a shell script, whereas i am able to connect to sql directly. It was working properly earlier, no clue why i am getting this. Please find the log below: FTP to <IP> completed Wed Apr 30 11:42:01 BST 2008 Program ended. Wed Apr 30... (1 Reply)
Discussion started by: nehak
1 Replies

9. Shell Programming and Scripting

Calling SQL LDR and SQL plus scripts in a shell script

Hi- I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment... I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert... (5 Replies)
Discussion started by: rajagavini
5 Replies

10. Shell Programming and Scripting

Error while trying to fire a PL/SQL thro Unix Script

hi , I tried running a PL/SQL script through unix shell script. But am getting the following error. "Message file sp1<lang>.msb not found Error 6 initializing SQL*Plus " Kindly suggest. Regards, Samit (5 Replies)
Discussion started by: dharmesht
5 Replies
Login or Register to Ask a Question