الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

خطأ في ال Trigger

بدأه b2it في 24 أبريل 2008 · 3 رد · 789 مشاهدة · في قواعد بيانات Microsoft SQL Server
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

(inserted) الكود التالي لا يقبل كلمة

أبدآ أرجو المساعدة

use std 
go



CREATE TRIGGER dbo.tb_term ON dbo.total_marks 
AFTER INSERT
AS BEGIN if ( Select sub_no from sub_hold where reg_no= INSERTED.reg_no and term_no = Inserted.term_no and level_no= Inserted.level_no
)>=1

-- SET NOCOUNT ON added to prevent extra result sets from <span style='color:orange'>-- interfering with SELECT statements.

declare @sumsub float
declare @sumsub_h float
declare @sum_term float

select @sumsub= total_h_m from total_marks where reg_no= Inserted.reg_no and term_no= Inserted.term_no and level_no=Inserted.level_no


Select @sumsub_h=sum(dbo.subjects.h_no) FROM dbo.subjects INNER JOIN dbo.total_marks ON dbo.subjects.sub_no = dbo.total_marks.sub_no 
where reg_no=Inserted.reg_no and total_marks.term_no =Inserted.term_no and total_marks.level_no=Inserted.level_no


update term_mark set total_pm = total_pm + (@sumsub/@sumsub_h) 
where term_no= Inserted.term_no and level_no = Inserted.level_no

-- Insert statements for trigger here

END 

GO

#2

for insert وليس after insert هذيك في اوراكل .

#3

(inserted.field name)لوسمحتوا مازالت نفس الرسالة لا يقبل كلمة

#4

السلام عليكم

الجدول inserted يجب معاملته كأي جدول .

فانت تعمل استعلام دون وضع اسم الجدو ل Inserted عند جملة From فمثلا يمكنك عمل مايلي :

فالاستعلام الاول يجب ان يكون كمايلي

select @sumsub= total_h_m from total_marks inner join inserted on reg_no= Inserted.reg_no and term_no= Inserted.term_no and level_no=Inserted.level_no

او مثل الاوراكل

select @sumsub= total_h_m from total_marks, inserted where total_h_m.reg_no= Inserted.reg_no and total_h_m.term_no= Inserted.term_no and total_h_m.level_no=Inserted.level_no

وهكذا لبقية الاستعلامات

مواضيع مشابهة