See Scripts in Operating System
A real shell Unix calling Oracle
#!/bin/ksh
sqlplus "/ as sysdba" <<ENDOFSQL
spool ./start_work.log
whenever sqlerror exit sql.sqlcode;
variable result number
declare
s varchar2(20);
begin
select in_progress into s from etl.load_status;
if(s='Y') then
raise_application_error(-20001, 'Process in progress');
end if;
update etl.load_status set in_progress='Y', process_date=sysdate;
commit;
:result := 1;
end;
/
exit 1;
ENDOFSQL
echo $?
|
Using SqlPlus SQL>variable mgr varchar2(5); SQL>execute :mgr:='A'; SQL>select * from aldo.aziende where nomefiliale = :mgr; |
Template--FILENAME : --Author : --Date : --Application : --Run this script with user: --Notes : --create views with FORCE option whenever oserror exit SQL.OSCODE rollback whenever sqlerror exit SQL.SQLCODE rollback spool NOMEFILE.log Set autocommit off timing on echo on feedback on --your sql --commit spool off exit |
| Template for unix scripts unix>vi scriptSQL.sql
unix>nohup sqlplus "/ as sysdba" @scriptSQL.sql & Template using progress indicator, only for begin - end blocks
unix> nohup sqlplus "/ as sysdba" @scriptSQL.sql 'Analyzing' 3 'ALDO' & |
Another way to launch a script echo "execute EODPHASE.EOD.insertAndLaunch(mBankId=> 'NLH', mVerifyDate=>sysdate);" | sqlplus "eodphase/eodphase@mta-a-st-grid" |
SQLPLUS tipsAllow to specify logfile using a parameter spool check_trand_DB_&&1..log |