2013-02-22 44 views
0

我在聲明塊中收到錯誤。我在代碼下面粘貼了它。SQLPLUS聲明塊中的錯誤

function XYZ 
{ 
     sqlplus -s $DB_USR/[email protected]$SID 
     set timing off 
     set serveroutput on size 10000 
     set feedback off 
     spool logname_$sid.out 

     variable ex_code number 
     whenever sqlerror exit 1 
     begin 
       :ex_code :=0; 
     end; 
     /


     declare 

     l_cnt number := 0; 
     l_sql varchar2(4000) := ''; 
     l_tmp_name varchar2(100) := ''; 
    some more code... 

} 

./XYZ.sh:線26:鄰近意外的標記語法錯誤`( '
./XYZ.sh:線26:`l_sql VARCHAR2(4000):= '';'
-bash-3.2 $

誰能告訴我是什麼原因造成的問題

+1

究竟是什麼代碼? PL/SQL還是bash? – 2013-02-22 19:40:03

回答

0

我想你想在這裏的文檔,假設sqlplus從標準輸入讀取:

function XYZ 
{ 
     sqlplus -s $DB_USR/[email protected]$SID <<-EOF 
     set timing off 
     set serveroutput on size 10000 
     set feedback off 
     spool logname_$sid.out 

     variable ex_code number 
     whenever sqlerror exit 1 
     begin 
       :ex_code :=0; 
     end; 
     /


     declare 

     l_cnt number := 0; 
     l_sql varchar2(4000) := ''; 
     l_tmp_name varchar2(100) := ''; 
     some more code... 
     EOF 
} 
+0

這工作!感謝您的答覆。 – itsh 2013-02-23 00:10:11