ls
sqlplus berke/berke << eof
select sysdate from dual;
declare
begin
dbms_output.put_line('abcde');
end;
/
exit;
/
eof
ls
 ./abcd.sh  
 abcd.sh     addm      awr       db_control.sh  
 abcd.sh1    addmrpt.sql   awrrpt.sql   db_control.sql  
   
 SQL*Plus: Release 11.2.0.2.0 Production on Thu Mar 20 15:22:32 2014  
   
 Copyright (c) 1982, 2010, Oracle. All rights reserved.  
   
   
 Connected to:  
 Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production  
 With the Partitioning, Automatic Storage Management, OLAP, Data Mining  
 and Real Application Testing options  
   
 SQL> SQL> SQL>   
 SYSDATE  
 ---------  
 20-MAR-14  
   
 SQL>  2  3  4  5 abcde  
   
 PL/SQL procedure successfully completed.  
   
 SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production  
 With the Partitioning, Automatic Storage Management, OLAP, Data Mining  
 and Real Application Testing options  
 abcd.sh     addm      awr       db_control.sh  
 abcd.sh1    addmrpt.sql   awrrpt.sql   db_control.sql  -Klasör içerisindeki SQL script'ini çalıştırmak için kısaca script'imizin başına '@' işaretini ekleyerek devam edebiliriz.
sqlplus berke/berke @abcd.sql   sqlplus -s "/ as sysdba" @$ORACLE_HOME/rdbms/admin/awrrpt.sql sqlplus berke/berke << -eof
select sysdate from dual;
exit;
/
eof
-SQL*PLUS'ta çalıştırdığımız bir sorgunun sonucunu alıp bir değişkene atamak içinse aşağıdaki örneği kullanabiliriz. Burada "code" adlı değişkenimize değerimizi atamak için değerimizi sqlplus'tan gönderdiğimiz sorguyla atarız.
code=""
code=$(sqlplus -s berke/berke <
select sysdate from dual where 1=2;
EOF)
a=$(code)
if [ "$a" == "no rows selected" ]; then
echo "Tarih çıkmadı"
else
echo "Tarih $a"
 
 
Hiç yorum yok:
Yorum Gönder