Reputation: 976
I have a problem with my sql code. I try co create a trigger which will sum how much I earned after 'closing' the excursion. By closing I mean update a row and type there charge (payment), date and time.
Here's the table:
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
);
And here is this trigger which has an errors:
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;
The error shows this:
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
Probably there is a problem with this if statement, but I can't find out what is wrong. Thanks in advance.
Upvotes: 0
Views: 17508
Reputation: 1
if
statement in PLSQL
should end with end if
;
After DBMS_OUTPUT
try below
END IF;
END;
/
This should work.
Upvotes: 0
Reputation: 1270793
I'm pretty sure your problem is smart quotes. Try replacing with regular single quotes. So, replace this line:
dbms_output.put_line(‘We’ve earned’||sumofearning);
With this line:
dbms_output.put_line('We’ve earned'||sumofearning);
Upvotes: 1