Newbie!! how do I create a trigger in my forms [message #232644] |
Sun, 22 April 2007 18:05 |
ladygunner
Messages: 1 Registered: April 2007
|
Junior Member |
|
|
Greetings,
I am relatively new to forms and trying to learn as quickly as possible. But I have run into a roadblock trying to learn triggers.
I have a program, but when I run the program to create a WHEN_VALIDATE_ITEM trigger, I get a ERROR 201 - need to declare the identifier, which in this case is "products"
I am including the entire program as I have listed in my textbook
Any assistance in helping me to complete this, is greatly appreciated.
-Denice
DECLARE
NumberOfProducts NUMBER
BEGIN
SELECT count(*)
INTO NumberOfProducts
FROM products
WHERE products.MemberID = :members.MemberID;
IF NumberOfProducts = 0 THEN
IF :members.salary NOT BETWEEN 10000 AND 75000 THEN
message ('With no products, salary must be 10K-75K');
RAISE FORM_TRIGGER_FAILURE;
END IF;
ELSE
IF :members.salary NOT BETWEEN 20000 AND 85000 THEN
message ('With products, salary must be 20K-85K');
RAISE FORM_TRIGGER_FAILURE;
END IF;
END IF;
END;
Upd-mod: Please read the stickies at the beginning of this forum.
[Updated on: Sun, 22 April 2007 21:30] by Moderator Report message to a moderator
|
|
|
|
Re: Newbie!! how do I create a trigger in my forms [message #232835 is a reply to message #232644] |
Mon, 23 April 2007 09:07 |
imen_mr2004
Messages: 22 Registered: October 2006 Location: tunisia
|
Junior Member |
|
|
try to manage an exception, just try these intructions
DECLARE
NumberOfProducts NUMBER
BEGIN
begin
SELECT count(*)
INTO NumberOfProducts
FROM products
WHERE products.MemberID = :members.MemberID;
exception when others then NumberOfProducts:=0;
end;
IF NumberOfProducts = 0 THEN
IF :members.salary NOT BETWEEN 10000 AND 75000 THEN
message ('With no products, salary must be 10K-75K');
RAISE FORM_TRIGGER_FAILURE;
END IF;
ELSE
IF :members.salary NOT BETWEEN 20000 AND 85000 THEN
message ('With products, salary must be 20K-85K');
RAISE FORM_TRIGGER_FAILURE;
END IF;
END IF;
END;
Good luck;
don't forget to focus if u hav wrote he right name of table and columns, and if u had logged on.
|
|
|