2014-01-21 53 views
0

我的sql代碼有問題。我嘗試創建一個觸發器,它將總結我在「關閉」遊覽之後獲得的收入。通過關閉我的意思是更新一行並輸入收費(付款),日期和時間。PLS-00103:遇到下列其中一項時遇到符號「'」:()

這裏的表:

create table Excursion(
excIDExcursion NUMBER(4) PRIMARY KEY , 
excStartDate date not null, 
excStartTime varchar(5) not null, 
excEndDate date, 
excEndTime varchar(5), 
excpayment number(8), 
cIDCustomer number(4) references Customer, 
ID_TaxiCab number(4) references TaxiCab 
); 

這裏是這個觸發器,它有一個錯誤:

create or replace trigger HowMuchWeEarned 
after update on Customer 
for each row 
declare sumofearning number; 
begin 
if(excendtime!='' and exceenddate!=null) 
then 
Select sum(excpayment) into sumofearning from Excursion; 
dbms_output.put_line(‘We’ve earned’||sumofearning); 
end; 
/
show errors; 

錯誤表明這一點:

PLS-00103: Encountered the symbol "‘" when expecting one of the f ollowing: () - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> table c ontinue avg count current exists max min prior sql stddev sum variance execute multiset the both leading trailing forall mer ge year month day hour minute second timezone_hour timezone_mi nute timezone_region timezone_abbr time timestamp interval dat e <a string literal with character set specificatio 

有可能是一個問題這個if語句,但我找不出什麼是錯的。 在此先感謝。

回答

1

我很確定你的問題是智能報價。嘗試用常規單引號替換。因此,更換這行:

dbms_output.put_line(‘We’ve earned’||sumofearning); 

這一行:

dbms_output.put_line('We’ve earned'||sumofearning); 
+0

感謝您的幫助! :) 不幸的是,現在它顯示了另一個問題: PLS-00103:遇到符號「;」當期待以下其中一個時:如果 – Ganjira

0

if聲明PLSQLend if結束; DBMS_OUTPUT後試試下面

END IF; 
END; 
/

這應該工作。

相關問題