![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Generic Shell Script to Archive a file | mak1600 | Shell Programming and Scripting | 8 | 07-26-2008 09:51 AM |
| script for purge | JP003 | Shell Programming and Scripting | 1 | 07-11-2008 07:42 AM |
| File Archive Script | KeesH | Shell Programming and Scripting | 10 | 06-09-2008 12:11 PM |
| making a archive script | jimmyc | Shell Programming and Scripting | 1 | 09-15-2007 05:02 AM |
| Read from file then purge or archive. | kayarsenal | Shell Programming and Scripting | 15 | 08-10-2006 09:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
shell script for archive purge
I am writing a shell script for Archive Purge for the table having rows < 1 year. The shell script has to extract the rows from the table and write those extracted rows to a text file. Then from the text file, each rows will be read and deleted by means of delete query one by one. The fields will be defined by means of position. For Eg. ZB_RCVBL_TRACKER consists of the fields as follows. PCN, ACCNO, TRANCD, AMOUNT, LOB_TIMESTAMP After the rows are extracted and written in to a text file. I need to get the fields PCN, ACCNO, TRANCD, LOB_TIMESTAMP from the text file and pass those values to the query DELETE FROM ZB_RCVBL_TRACKER where PCN = ? and ACCNO=? and TRANCD = ? and LOB_TIMESTAMP = ? If the SQLCODE is 0, I can proceed furthur. Can anyone help me to achieve this task. Code:
================================== #! /bin/ksh ############################ # AFI Monitor Script ############################ . /db2/uszlad48/sqllib/db2profile export mondir=/home/bmwdev1/script/krishna export monlog=$mondir/Error_Report_`date +%Y%m%d`.log export bakdir=/home/bmwdev1/script/krishna/bkup export baklog=$bakdir/Error_Report_`date +%Y%m%d`_bkup.log # connect to DB #echo "connect to database r2pdev" >>$monlog # extract the eligible rows from the table db2 "SELECT * FROM ZB_RCVBL_TRACKER WHERE TIMESTAMP_UPDATED < (SYSDATE – 1 YEAR)WITH UR" >> $monlog echo "After SQL execution" >> $monlog ================================== Krishnakanth |
|
||||
|
Thank you for your reply Johnson.
Here the problem is how to read PCN, ACCNO, TRANCD, AMOUNT, LOB_TIMESTAMP from a text file. The data will be as follows in the text file. Quote:
Is it possible to do like as follows. pcn is 7 byte starting from 1 to 7 accno is 9 byte starting from 9 to 17 tran_cd is 2 byte starting from 19 to 20 amount is 8 byte starting from 22 to 29 LOB_TIMESTAMP is 26 byte starting from 30 to 55 can we define like this and will pass data. If so how to define in shell script ? Could you please let me know how to proceed furthur. Krishnakanth |
|
||||
|
Johnson,
The script that you have given works fine. But in my case it is a different one. I have given the sample what I am working now. Let me give you the exact one what i am working currently. following is the data in a text file.(db2 "SELECT TRACKING_NUM, TRACKING_NUM_SUFFIX, ERROR_SRC_CD, MSG_NUM, MSG_ID, MSG_TYP, MSG_TEXT, TIMESTAMP_UPDATED, USER_UPDATED FROM ZB_RCBL_ERROR_MSG_MIG WITH UR" >> $monlog1) Quote:
Quote:
Please let me know how to proceed furthur. Krishnakanth |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|