Created
February 22, 2013 11:50
-
-
Save jgcasta/5012941 to your computer and use it in GitHub Desktop.
Delete oracle old entries shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Delete 1 year before today | |
# | |
# 20/02/2013 v1.0 | |
# | |
# | |
ANO=$(date +%Y) | |
ANTERIOR=$[ANO-1] | |
FBORRADO=$(date +%d-%m-$ANTERIOR) | |
MES=$(date +%m) | |
MESANTERIOR=$[MES-1] | |
if [ $MESANTERIOR -lt 1 ]; then | |
MESANTERIOR=12 | |
ANO=$ANTERIOR | |
fi | |
FBORRADO2=$(date +%d-$MESANTERIOR-$ANO) | |
SENTENCIA1="delete from historico where HIST_FECHAALTA < to_date('$FBORRADO','dd-mm-yy');" | |
sqlplus -s /nolog << EOF | |
set echo on | |
connect user/pass@dest | |
$SENTENCIA1 | |
commit; | |
exit sql.sqlcode | |
EOF | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment