UNIX with DB2 error status Issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX with DB2 error status Issue
# 8  
Old 02-05-2018
Already done in post#4. Try
Code:
return $EXIT_DB2

EDIT: or, as proposed by rbatte1 below, exit $EXIT_DB2.

Last edited by RudiC; 02-05-2018 at 06:37 AM.. Reason: added correction as proposed by rbatte1
# 9  
Old 02-05-2018
If you detect an error in dbscript.ksh and you want to pass that back to main.ksh, the usual way to is for dbscript.ksh to exit with a return code. You can do this:-
Code:
db2 "export to $exportfilepath/abc.ixf of IXF select * from table with UR" #Here I am selecting from various tables and conditions.There is an error and it is working fine
EXIT_DB2=$?
if [[ $EXIT_DB2 -ne 0 ]]; then
        echo "Run Status is : Fail"
        exit $EXIT_DB2
else
        echo "Run Status is : Success" 
        exit $EXIT_DB2            # Will be zero, but nice to be consistent
fi



I hope that this helps,
Robin
This User Gave Thanks to rbatte1 For This Post:
# 10  
Old 02-05-2018
If the exit $EXIT_DB2 exists in either branch, you might consider using it after the if construct.
This User Gave Thanks to RudiC For This Post:
# 11  
Old 02-07-2018
Thanks for input.I faced one Issue here.Here I am exporting the data from tables to abc.ixf.Before export operation[I mean db2 select] is completed it is executing next command EXIT_DB2=$?.
I want EXIT_DB2=$? to be executed only after completion of db2 export command

Code:
db2 "export to $exportfilepath/abc.ixf of IXF select * from table with UR" #Here I am selecting from various tables and conditions.There is an error and it is working fine
EXIT_DB2=$? #I want to trigger this one once above export operation is completed
if [[ $EXIT_DB2 -ne 0 ]]; then
        echo "Run Status is : Fail"
        exit $EXIT_DB2
else
        echo "Run Status is : Success" 
        exit $EXIT_DB2            # Will be zero, but nice to be consistent
fi

---------- Post updated 02-07-18 at 01:24 AM ---------- Previous update was 02-06-18 at 03:51 AM ----------

Hi All,

Could anybody help on this issue?

Last edited by vamsi.valiveti; 02-06-2018 at 05:06 AM..
# 12  
Old 02-07-2018
Quote:
Originally Posted by vamsi.valiveti
Thanks for input.I faced one Issue here.Here I am exporting the data from tables to abc.ixf.Before export operation[I mean db2 select] is completed it is executing next command EXIT_DB2=$?.
I want EXIT_DB2=$? to be executed only after completion of db2 export command

Code:
db2 "export to $exportfilepath/abc.ixf of IXF select * from table with UR" #Here I am selecting from various tables and conditions.There is an error and it is working fine
EXIT_DB2=$? #I want to trigger this one once above export operation is completed
if [[ $EXIT_DB2 -ne 0 ]]; then
        echo "Run Status is : Fail"
        exit $EXIT_DB2
else
        echo "Run Status is : Success" 
        exit $EXIT_DB2            # Will be zero, but nice to be consistent
fi

---------- Post updated 02-07-18 at 01:24 AM ---------- Previous update was 02-06-18 at 03:51 AM ----------

Hi All,

Could anybody help on this issue?
It is hard to help on an issue if we don't understand what issue is troubling you.

You have shown us code with comments saying it is working fine.

What is the problem?

Is db2 another shell script you have written? Are you saying that it doesn't return a non-zero exit code when it fails?

Are you saying that db2 starts a database operation asynchronously and returns before the operation completes? If this is your problem, you're stuck. A parent can wait for its child to exit and gather its exit status. A grandparent can't get the exit status of any of its grandchildren unless that grandchild's parent made it available to the grandparent.
# 13  
Old 02-07-2018
I want to trigger EXIT_DB2=$? command after completion of db2 export command but the problem here is EXIT_DB2=$? is triggering before completion of export process

Code:
db2 "export to $exportfilepath/abc.ixf of IXF select * from table with UR" 
EXIT_DB2=$? #I want to trigger this one once above export operation is completed but this command is triggering before export operation is completed
if [[ $EXIT_DB2 -ne 0 ]]; then
        echo "Run Status is : Fail"
        exit $EXIT_DB2
else
        echo "Run Status is : Success" 
        exit $EXIT_DB2            # Will be zero, but nice to be consistent
fi

# 14  
Old 02-07-2018
I repeat: If db2 is starting a database operation asynchronously and exiting before that database operation completes, there is no way for a script that invokes db2 to determine what the exit code was (or will be) for the database operation when it completed (or when it completes later).

If you would like to show us the source code for db2 we might be able to help you fix it so that your script can get the data it wants.
These 2 Users Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to track table status delete/update/insert status in DB2 V10 z/os?

Dear Team I am using DB2 v10 z/os database . Need expert guidance to figure out best way to track table activities ( Ex Delete, Insert,Update ) Scenario We have a table which is critical and many developer/testing team access on daily basis . We had instance where some deleted... (1 Reply)
Discussion started by: Perlbaby
1 Replies

2. Programming

DB2 - Performance Issue using MERGE option

Dear Team, I am using DB2 v10.5 and trying to load huge data using MERGE option ( 10-12 Million) using below query. Basically it loads data from staging to target . Staging table schemaname.Customer_Staging has 12 Million records . Runs for 25 Mins for just select query. But while doing merge... (2 Replies)
Discussion started by: Perlbaby
2 Replies

3. Shell Programming and Scripting

Issue on executing db2 queries through shell script

hi i am trying to execute db2 queries through shell script. it's working fine but for few queries is not working ( those queries are taking time so the script is not waiting to get the complete the execution of that query ) could you please any one help me on this is there any wait... (1 Reply)
Discussion started by: bhaskar v
1 Replies

4. Shell Programming and Scripting

/db2home full issue in db2

Hi all, I am new for linux environment, and i am working as a DBA. I am facing some issues in OS level: In our dev boxes /db2home under this directory i'm not finding any folder but it's showing 98% used . /dev/dm-14 5.0G 4.6G 115M 98% /db2home # ls -lrt total 16... (1 Reply)
Discussion started by: suresh_target
1 Replies

5. UNIX for Dummies Questions & Answers

How to connect to DB2 using UNIX

I am new to Putty, Unix and DB2 and this is what I am working on right now. I installed Putty I got access to username / pwd I got Unix usrname/Pwd.also got the home directory once I login into putty I get the screen and it shows $ sign From here how do I connect to DB2 database? I have... (2 Replies)
Discussion started by: JayDoshi
2 Replies

6. Shell Programming and Scripting

Unix and db2 where condition issue(new line)

Hi I am extracting a column value(DESCRIPTION) from one table and passing it to another db2 statement in a shell code to fetch some value(ID) but the value when passed in where condition is taking as newline+value. Please find the out put when executed: + echo description is ::::... (1 Reply)
Discussion started by: msp2244
1 Replies

7. Shell Programming and Scripting

DB2 Connect issue

Hi i m trying to connect DB2 via unix. it is successfully connect. but the connect is getting disconnect . below is the query , countvalue=$(db2 "connect to <Database> user <username> using <Password>" | db2 -x 'select count(*) from <tablename>' ); echo $countvalue while... (2 Replies)
Discussion started by: baskivs
2 Replies

8. Shell Programming and Scripting

Connect status of db2 in Unix shell script

Hi I am trying to connect to db2 database from Unix shell script (k shell) I need to catch the status of connect whether it is succesful or not. ---------------------------------------------------------- # Read login credentials for db2 tput clear echo "Please enter your Userid:\c"... (3 Replies)
Discussion started by: mKarri
3 Replies

9. Shell Programming and Scripting

need help with UNIX, awk and DB2

Hi i am working on a script which takes a parameter file as input . this parameter file is having SQL statements. I am fetching column names from the output of SQL file using following code: while read Record1 do SQLQuery=`echo $Record1 | awk '{printf $0 }'` ... (2 Replies)
Discussion started by: manmeet
2 Replies

10. Red Hat

Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58

I have successfully installed RedHat 8.0 onto a Dell PowerEdge SC1425 today. This server has two SATA hard drives, and an IDE DVD-ROM drive. Using the following kernel parameters, i successfully installed across both hard drives from CD: ide0=0x1f0,0x3f6,14 vga=791 resolution=1024x768 expert... (5 Replies)
Discussion started by: fishsponge
5 Replies
Login or Register to Ask a Question