how to use befores insert trigger

Posted by Shanky11 under Others on 8/28/2012 | Points: 10 | Views : 584 | Status : [Member] | Replies : 3
canot update 'score' in stored function /trigger because it is already use d ny statement whicjh invoked this stored function /trigger
create trigger trgscore
BEFORE INSERT ON score
FOR EACH ROW
BEGIN
UPDATE score SET hindi=hindi+10;
END



Table student
sid name emaIL tABLE SCORE MATHS SCI HINDI TOTAL SID




Responses

Posted by: Nkkppp on: 8/28/2012 [Member] Starter | Points: 25

Up
0
Down
SQL server doesn't support before insert triggers like Oracle.

Use Instead of trigger(included in which is similar to before triggers in Oracle.

Please let me know if you need the query for the same.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/13/2012 [Member] Bronze | Points: 25

Up
0
Down
A BEFORE INSERT Trigger means that Oracle will fire this trigger before the INSERT operation is executed.

The syntax for an BEFORE INSERT Trigger is:

CREATE or REPLACE TRIGGER trigger_name
BEFORE INSERT
ON table_name
[ FOR EACH ROW ]
DECLARE
-- variable declarations
BEGIN
-- trigger code
EXCEPTION
WHEN ...
-- exception handling
END;

trigger_name is the name of the trigger to create.
Restrictions:

You can not create a BEFORE trigger on a view.
You can update the :NEW values.
You can not update the :OLD values.


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Shanky11,
Please Mark as Answer if it helpful to you..That helps other who search the same...



Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response