SQLinfo.ru - Все о MySQL

Форум пользователей MySQL

Задавайте вопросы, мы ответим

Вы не зашли.

#1 14.10.2008 13:14:07

Akma
Участник
Зарегистрирован: 14.10.2008
Сообщений: 2

Zdraste, mozhno li sozdat' trigger kotorii otmenyaet' vvod dannih esly ne sootvetstvuet usloviyu

mne nuzhno sozdat' trigger, kotorii do togo kak vvedet dannie v tablicu proveret takoe uslovie chto:

create trigger boatbook on booking
for each row  begin
if (new.bid=bid and new.hire_date< retn_date) then cancel insert
end if
end;

no mysql vidaet mne oshibku o 4 linii koda. ne poimu v chem delo?
pomogite pozhalsta.

etot trigger dolzhen proverit' bid - identificator lodki, kotoraya budet zareserviravona. kogda reserviruetsa lodka mi ukazivaem hire_date - data reservirovaniya i retn_date - data vozvrasheniya. Cel' takova shto nel'zya zabronirovat' lodku kotoraya uzhe zabronirovana i eshe ne vernulas'.

sama tablica viglyadir tak:

create table booking(
bookid varchar(5) not null primary key,
cid varchar(5) not null references customer(cid) on delete no action on update cascade,
bid varchar(4) not null references boat(bid) on delete no action on update cascade,
hire_date date not null,
retn_date date not null,
constraint cust_hire unique (cid, hire_date),
constraint cust_retn unique (cid, retn_date),
constraint boat_hire unique (bid, hire_date),
constraint boat_retn unique (bid, retn_date));

podskazhite pozhaluista kak mozhno sozdat' danni trigger?

Неактивен

 

Board footer

Работает на PunBB
© Copyright 2002–2008 Rickard Andersson