How to create a table for blurtanalysis using CREATE TRIGGER

How to create a table for blurt_analysis using CREATE TRIGGER

blurt_analysis (email, blurtid, topicid, confidence, sentiment) primary key(email, blurtid, topicid) foreign key(email, blurtid) references blurt(email, blurtid) foreign key(topicid) references topic(id) constraint confidence >= 0 and confidence = -5 and sentiment

Solution

Solution is using SQL server.

It checks for the data in the given range it will commit else its going to roll back and raise the error message.

It triggers for every insertion

CREATE TRIGGER trgInsteadOfInsert ON blurt_analysis

INSTEAD OF Insert

AS

declare @confidence int, @sentiment int;

select @confidence=i.confidence from inserted i;

select @sentiment=i.@sentiment from inserted i;

BEGIN

BEGIN TRAN

SET NOCOUNT ON

if((@confidence>=0 and @confidence<=10) or( @sentiment>=-5 and @sentiment<=5))

begin

RAISERROR(\'error message goes here\',16,1); ROLLBACK; end

COMMIT;

END

How to create a table for blurt_analysis using CREATE TRIGGER blurt_analysis (email, blurtid, topicid, confidence, sentiment) primary key(email, blurtid, topici

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site