-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaaa.sh
More file actions
86 lines (68 loc) · 2.36 KB
/
aaa.sh
File metadata and controls
86 lines (68 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash -x
BASE_PATH="/home/oracle/UTIBA_INCREMENTAL"
OUTPUT_TRANS=$BASE_PATH/trans.txt
OUTPUT_TRANS_DATA=$BASE_PATH/transData.txt
OUTPUT_TRANS_PARTY=$BASE_PATH/transParty.txt
OUTPUT_REVERSAL=$BASE_PATH/reversal.txt
OUTPUT_COUPON=$BASE_PATH/coupon.txt
OUTPUT_COUPON_DATA=$BASE_PATH/couponData.txt
TEMP_FILE=$BASE_PATH/temp.txt
LOG_FILE=$BASE_PATH/incrementalDumpTransData.txt
DB=//192.168.2.5:1521/utiba
DB_USER=umarketadm
DB_PSW=spice#123
>$OUTPUT_TRANS
>$OUTPUT_TRANS_DATA
>$OUTPUT_TRANS_PARTY
>$OUTPUT_REVERSAL
>$OUTPUT_COUPON
>$OUTPUT_COUPON_DATA
TRANS_ID=36365938
echo "Dump started at `date`." >>$LOG_FILE
sqlplus ${DB_USER}/${DB_PSW}\@${DB} <<EOF
whenever sqlerror exit sql.sqlcode;
set colsep ','
set echo off
set feedback off
set line 20000
set pagesize 50000
set echo off
set heading on
set sqlprompt ''
set trimspool on
set headsep off
spool '$OUTPUT_TRANS'
SELECT * FROM TRANS WHERE LAST_MODIFIED > '10-04-18 12:29:14.138000000 AM' and rownum<10;
spool off
exit;
spool '$OUTPUT_TRANS_DATA'
SELECT * FROM TRANS_DATA WHERE LAST_MODIFIED > '10-04-18 12:34:45.500000000 AM';
spool off
spool '$OUTPUT_TRANS_PARTY'
SELECT * FROM TRANS_PARTY WHERE LAST_MODIFIED > '10-04-18 12:34:45.500000000 AM';
spool off
spool '$OUTPUT_REVERSAL'
SELECT * FROM REVERSAL;
spool off
spool '$OUTPUT_COUPON'
SELECT count(*) FROM COUPON;
spool off
spool '$OUTPUT_COUPON_DATA'
SELECT count(*) FROM COUPON_DATA;
spool off
exit;
EOF
cat $OUTPUT_TRANS | grep -v "^-" | sed -e 's/\t//g' | sed -e 's/ *//g' | grep -v "^$" | sed -e 's/_/ /g' > $TEMP_FILE
mv $TEMP_FILE $OUTPUT_TRANS
cat $OUTPUT_TRANS_DATA | grep -v "^-" | sed -e 's/\t//g' | sed -e 's/ *//g' | grep -v "^$" | sed -e 's/_/ /g' > $TEMP_FILE
mv $TEMP_FILE $OUTPUT_TRANS_DATA
cat $OUTPUT_TRANS_PARTY | grep -v "^-" | sed -e 's/\t//g' | sed -e 's/ *//g' | grep -v "^$" | sed -e 's/_/ /g' > $TEMP_FILE
mv $TEMP_FILE $OUTPUT_TRANS_PARTY
cat $OUTPUT_REVERSAL | grep -v "^-" | sed -e 's/\t//g' | sed -e 's/ *//g' | grep -v "^$" | sed -e 's/_/ /g' > $TEMP_FILE
mv $TEMP_FILE $OUTPUT_REVERSAL
cat $OUTPUT_COUPON | grep -v "^-" | sed -e 's/\t//g' | sed -e 's/ *//g' | grep -v "^$" | sed -e 's/_/ /g' > $TEMP_FILE
mv $TEMP_FILE $OUTPUT_COUPON
cat $OUTPUT_COUPON_DATA | grep -v "^-" | sed -e 's/\t//g' | sed -e 's/ *//g' | grep -v "^$" | sed -e 's/_/ /g' > $TEMP_FILE
mv $TEMP_FILE $OUTPUT_COUPON_DATA
echo "Dump completed at `date`." >>$LOG_FILE
exit