Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Records not dropped from UNIX Script

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-19-2017
suresh_target suresh_target is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 19 June 2017, 5:02 AM EDT
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Records not dropped from UNIX Script

Hi All,
As per my biz requirement, I need to drop the partition from our PROD table based on the retention period.

Hence I have written the script and called the drop partition procedure within the script.

The procedure is working fine and droped the partition from the table when I execute alone but when I call the procdure from the script itself, paritions are not dropped and throwing error. I really don't have any idea what is the reason for records are not dropped from the script.

Kindly provide your update on this.

Scriptname:drop_part_w56.sh


Code:
#!/bin/ksh

#Batchdate=20170616
#retn=$2
freq='W'
instance=DPHK0
dbuser=etl
dbpass=dummy

path=/CBS/HK/Temp

BatchDate=20170616

logfile=STATUS_w286_tmp_tab_$BatchDate.log

rm -f $path/$logfile

set +x

db2 connect to DPHK0 user etl using dummy

db2cmd=CALL HPPDWSG0.PARTITION_CLEANUP_PROC('SG','$BatchDate','W',?)";
echo ${db2cmd}
db2 +c -tv "${db2cmd}" >> $path/$logfile

db2 terminate

Error:


Code:
 Database Connection Information

 Database server        = DB2/AIX64 9.7.8
 SQL authorization ID   = ETL
 Local database alias   = DPHK0

/pdw/Singapore/simco/sit/pdwds_drop_part_w286.sh[38]: CALL HPPDWSG0.PARTITION_CLEANUP_PROC('SG','20170616','W',?):  not found

DB20000I  The TERMINATE command completed successfully.

Moderator's Comments:
Records not dropped from UNIX Script Please use CODE tags as required by forum rules!

Last edited by RudiC; 06-19-2017 at 04:03 AM.. Reason: Changed HTML to CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 06-19-2017
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 September 2017, 9:57 AM EDT
Location: Aachen, Germany
Posts: 11,370
Thanks: 298
Thanked 3,524 Times in 3,242 Posts
Did you compare the working directory when "executing alone" to when "calling from script"? And the PATH variable? You might want to use absolute paths.
Sponsored Links
    #3  
Old Unix and Linux 06-19-2017
suresh_target suresh_target is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 19 June 2017, 5:02 AM EDT
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for your input. Could you plz share some example.
However, I used the procedure script alone it was successful. Please see the details below.

Code:
/pd/SG/uat/EBBS> db2 connect to DPHK0 user etl
Enter current password for etl:

   Database Connection Information

Database server        = DB2/AIX64 9.7.8
SQL authorization ID   = ETL
Local database alias   = DPHK0


/pd/SG/uat/EBBS> db2 "CALL HPPDWSG0.PARTITION_CLEANUP_PROC('SG', '20170616','W', ?)";

  Value of output parameters
  --------------------------
  Parameter Name  : RESULT_STS
  Parameter Value : ALTER TABLE HPPDWSG0.CASA_ACCT_WK DETACH PARTITION P20170303 INTO HPPDWSG0.CAS_ACCT_WK_P20170303_DROP

    #4  
Old Unix and Linux 06-19-2017
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 September 2017, 9:57 AM EDT
Location: Aachen, Germany
Posts: 11,370
Thanks: 298
Thanked 3,524 Times in 3,242 Posts
Not sure what you mean by "share some example". What is the working directory (e.g. output of pwd command) in either case? From the error msg in the first and the command prompt in your second post one could infer they are different; that migt be the reason the script is not found.
Sponsored Links
    #5  
Old Unix and Linux 06-19-2017
cero cero is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 8 September 2017, 10:21 AM EDT
Posts: 458
Thanks: 4
Thanked 100 Times in 92 Posts
I think the script is not working because the opening doublequotes are missing when you assign the command to the variable.

Code:
#!/bin/ksh

#Batchdate=20170616
#retn=$2
freq='W'
instance=DPHK0
dbuser=etl
dbpass=dummy

path=/CBS/HK/Temp

BatchDate=20170616

logfile=STATUS_w286_tmp_tab_$BatchDate.log

rm -f $path/$logfile

set +x

db2 connect to DPHK0 user etl using dummy

db2cmd="CALL HPPDWSG0.PARTITION_CLEANUP_PROC('SG','$BatchDate','W',?)";
echo ${db2cmd}
db2 +c -tv "${db2cmd}" >> $path/$logfile

db2 terminate

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
UNIX Script required for count the records in table victory Shell Programming and Scripting 5 05-09-2014 08:21 AM
MySQL dropped in favor of MariaDB figaro News, Links, Events and Announcements 7 09-27-2013 11:33 AM
Recover dropped database Eastme SuSE 5 04-29-2009 10:01 PM
unix shell script which inserts some records into a file located in remote servers... techychap Shell Programming and Scripting 2 11-06-2008 12:07 AM
unix script for update or insert records from a file to a oracle table unihp1 UNIX for Advanced & Expert Users 1 06-11-2008 03:21 AM



All times are GMT -4. The time now is 11:08 PM.