我刚刚开始使用oracle,当我创建一个触发器时,会出现警告。没有错误消息,所以我很难调试。我认为查询是正确的。有人可以帮帮我吗?我很感激。
CREATE TRIGGER "TR_SERVICE_HISTORY_MESSAGE"
BEFORE INSERT OR UPDATE ON SERVICE_HISTORY
DECLARE FNAME(VARCHAR2 50);LNAME(VARCHAR2 50);DOGNAME(VARCHAR2 50);STOREAREA(VARCHAR2 50);DOGBREED(VARCHAR2 50);
BEGIN
IF(:NEW.FINISHED := 'T') THEN
SELECT F_NAME, L_NAME, DOG_NAME, STORE_AREA DOG_BREED
INTO FNAME, LNAME, DOGNAME, STOREAREA, DOGBREED FROM CUSTOMERS, DOGS, STORES
WHERE :NEW.DOG_ID = DOGS.DOG_ID, :NEW.STORE_ID = STORES.STORE_ID, CUSTOMER.C_ID = DOGS.C_ID;
:NEW.MESSAGE :='Hi '||FNAME||' '||LNAME||', your dog '||DOGNAME|| ' of breed: '||BREEDNAME||
' is ready for pick-up at '||STOREAREA||'.';
ELSE
SELECT F_NAME, L_NAME, DOG_NAME, DOG_BREED
INTO FNAME, LNAME, DOGNAME, DOGBREED FROM CUSTOMERS, DOGS, STORES
WHERE :NEW.DOG_ID = DOGS.DOG_ID, :NEW.STORE_ID = STORES.STORE_ID, CUSTOMER.C_ID = DOGS.C_ID;
:NEW.MESSAGE :='Hi '||FNAME||' '||LNAME||', your dog '||DOGNAME|| ' of breed: '||BREEDNAME||
' is not ready for picked up yet.';
END;
/
答案 0 :(得分:2)
代码中的一些非常基本的错误。这是一个至少是有效的plsql的代码块。
declare
fname varchar2(50);
lname varchar2(50);
dogname varchar2(50);
storearea varchar2(50);
dogbreed varchar2(50);
begin
if :new.finished = 'T'
then
select f_name
,l_name
,dog_name
,store_area dog_breed
into fname
,lname
,dogname
,storearea
,dogbreed
from customers
,dogs
,stores
where :new.dog_id = dogs.dog_id
and :new.store_id = stores.store_id
and customer.c_id = dogs.c_id;
:new.message := 'Hi ' || fname || ' ' || lname || ', your dog ' || dogname || ' of breed: ' ||
breedname || ' is ready for pick-up at ' || storearea || '.';
else
select f_name
,l_name
,dog_name
,dog_breed
into fname
,lname
,dogname
,dogbreed
from customers
,dogs
,stores
where :new.dog_id = dogs.dog_id
and :new.store_id = stores.store_id
and customer.c_id = dogs.c_id;
:new.message := 'Hi ' || fname || ' ' || lname || ', your dog ' || dogname || ' of breed: ' ||
breedname || ' is not ready for picked up yet.';
end if;
end;