to find whether update query is successfull or not using Ksh Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting to find whether update query is successfull or not using Ksh Script
# 1  
Old 01-06-2009
to find whether update query is successfull or not using Ksh Script

i have a script that performes an update operation. I just wanted to know whether that update statement is successfull or not.

Below the script:
Code:
#!/bin/ksh
. $HOME/conf/systemProperties/EnvSetup.properties
sqlplus -silent sie/da@edn.world <<END
set pagesize 0 feedback off verify off heading off trimspool on echo off
spool /ednadtu3/u01/pipe/naveed/class/Script_Fails.log 
UPDATE SIEBEL.S_ASSET_XM SDPX
SET SDPX.ATTRIB_03   = 'Inactive',
SDPX.LAST_UPD_BY = '1-42V',
SDPX.LAST_UPD    = SYSDATE,
SDPX.ATTRIB_04   = 'SQQ3'
 WHERE SDPX.PAR_ROW_ID  IN (select B.PAR_ASSET_ID from SIEBEL.s_asset_rel B
                                         where B.relation_type_cd= 'SDP-METER' ---- and X_rel_status= 'Active'
                                             and B.asset_id
                                                IN (select A.asset_num from SIEBEL.s_asset A where
                    A.x_electronic_id IN ( '090845086LG')))
   AND SDPX.ATTRIB_01   = 'AMR Ready'
   AND SDPX.ATTRIB_03   = 'Active';
commit;
spool off
exit;
END

I have use the concept of spool file but in my script the generated spool file "Script_Fails.log" is containg null values .Means a 0 byte spool file is getting created . The query works fine in my database and successfully creating spool file but using the script it's creating a 0 byte spool file.please help me in this

Below the spool file in SQL*Plus:
Quote:
SQL> UPDATE SIEBEL.S_ASSET_XM SDPX
2 SET SDPX.ATTRIB_03 = 'Inactive',
3 SDPX.LAST_UPD_BY = '1-42V',
4 SDPX.LAST_UPD = SYSDATE,
5 SDPX.ATTRIB_04 = 'SQQ3'
6 WHERE SDPX.PAR_ROW_ID IN (select B.PAR_ASSET_ID from SIEBEL.s_asset_rel B
7 where B.relation_type_cd= 'SDP-METER' ---- and X_rel_status= 'Active'
8 and B.asset_id
9 IN (select A.asset_num from SIEBEL.s_asset A where
10 A.x_electronic_id IN ( '090845086LG')))
11 AND SDPX.ATTRIB_01 = 'AMR Ready'
12 AND SDPX.ATTRIB_03 = 'Active';
0 rows updated.
SQL> commit;
Commit complete.
SQL> spool off
# 2  
Old 01-06-2009
Quote:
Originally Posted by ali560045
i have a script that performes an update operation. I just wanted to know whether that update statement is successfull or not.

Check the return code which is stored in "$?".
# 3  
Old 01-07-2009
Can you just explain me in detail as to where do i need to use that.
# 4  
Old 01-07-2009
Quote:
Originally Posted by ali560045
Can you just explain me in detail as to where do i need to use that.

Code:
sqlplus ... <<END
...
END
case $? in
     0) echo Success;;
     *) echo Failed ;;
esac

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Extract only the data from ksh script running netezza query

Hi I searched this forum before posting the question, but couldnt find it, the issue i'm facing is, i'm trying to select a column from a netezza table from a korn shell script, but the query runs var=$(nzodbcsql -q "select MAX(millcount) from table1";) echo $var it returns the value like... (10 Replies)
Discussion started by: maximus_jack
10 Replies

2. Shell Programming and Scripting

Shell Script (ksh) - SQLPlus query filter using a string variable

Using ksh, I am using SQLPlus to execute a query with a filter using a string variable. REPO_DB=DEV1 FOLDER_NM='U_nmalencia' FOLDER_CHECK=$(sqlplus -s /nolog <<EOF CONNECT user/pswd_select@${REPO_DB} set echo off heading off feedback off select subj_name from subject where... (5 Replies)
Discussion started by: nkm0brm
5 Replies

3. Shell Programming and Scripting

How to write a update query in perl script?

can any one suggest me on how to write a update query in perl script for Oracle database and also tell me abt how we can write a code for sending mails with report as attachment to appropriate persons? (1 Reply)
Discussion started by: Ramesh V Kumar
1 Replies

4. Shell Programming and Scripting

calling another script if it's contains SUCCESSFULL how?

Hi all, i'm a newbie here, I'm just wondering how can i call my second script if it's contain successfull. script1.sh how can i call my 2nd script if he contain SUCCESSFULL script2.sh SUCCESSFULL please advise, Thanks, (10 Replies)
Discussion started by: nikki1200
10 Replies

5. Shell Programming and Scripting

trying to run this script from unix but the script is not successfull

Hi I am trying to run the below unix script in informatica comamnd task the script is in placed in the path (this script checks if the files are present in other server ) ------------------------------------------------------------------... (1 Reply)
Discussion started by: laxmi131
1 Replies

6. Shell Programming and Scripting

Exit for loop in a shell script if a condition is successfull

Hi All, I am stuch in a script where a for loop is running to execute some commands for some values. Now my problem is i have to have an if condition that if the first iteration is successful then it has to exit the for loop otherwise it has to continue normally. my code is this: for... (5 Replies)
Discussion started by: usha rao
5 Replies

7. Shell Programming and Scripting

Tables to query to find users for database from shell script

I am coding shell script. I need to connect to different databases like DB2, Oracle and Sybase. I would then need to query tables where it has all the groups, users for that database. I would also need who has what kind of permissions. EG: I know for DB2 some TABAUTH table needs to be... (0 Replies)
Discussion started by: pinnacle
0 Replies

8. Shell Programming and Scripting

Script not successfull in cron

Hi, I have a script to FTP the files to other unit. Manually this script is running fine & files are getting transferred. But running the same script using crontab does not transfer files, although the cron log shows that the file was executed. PLz suggest (2 Replies)
Discussion started by: sandeep_kmehra
2 Replies

9. Shell Programming and Scripting

passing result of query to a varibale in ksh script

Hi, I have a scenario where in i have to extarct max of one column and pass it to a variable. i have tried to export the result as .dat file and read from that file.But my database is mainframe and it is not permitting me to export in .dat file.I have tried using .ixf file but reading from... (2 Replies)
Discussion started by: ammu
2 Replies
Login or Register to Ask a Question