Skip to content

Instantly share code, notes, and snippets.

@a2gs
Created March 12, 2019 20:00
Show Gist options
  • Save a2gs/54be89c67215caeca3a8f3a787f604b6 to your computer and use it in GitHub Desktop.
Save a2gs/54be89c67215caeca3a8f3a787f604b6 to your computer and use it in GitHub Desktop.
Shell script accessing Oracle DB little sample
#!/usr/bin/sh
DATA=`date +'%d%m%Y'`
TABELA=TABELA_ABC
CAMPO=DATA_CRIACAO
TEMPO=30
DB_USER=db_user
DB_PASSWORD=db_user_password
DB_INSTANCE=connection_instance
sqlplus "$DB_USER/$DB_PASSWORD@$DB_INSTANCE" << SQL_EOF > SQL_OUT.text
select * from $TABELA where $CAMPO >= TO_DATE('$DATA', 'DDMMYYYY')-$TEMPO;
commit;
SQL_EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment