0
create table student
(spnr VARCHAR(5) PRIMARY KEY,
sname VARCHAR(10),
saddress VARCHAR(10),
stel VARCHAR(10))
create table course
(ccode VARCHAR(5) PRIMARY KEY,
cname VARCHAR(10),
caddress VARCHAR(10),
points int)
create table studies
(id int PRIMARY KEY,
spnr VARCHAR(5) NOT NULL,
ccode VARCHAR(5) NOT NULL,
result int,
CONSTRAINT STUDIES_SPNR_FK FOREIGN KEY(spnr) REFERENCES student(spnr),
CONSTRAINT STUDIES_CCODE_FK FOREIGN KEY(ccode) REFERENCES course(ccode))
create trigger t1 on course
after update,insert
as
print 'inside trigger';
select i.ccode from inserted i, deleted d
where i. ccode = d. ccode
create procedure what (@tableName varchar(10))
as
begin
declare @name varchar(20);
declare c cursor for
select column_name
from information_schema.columns
where table_name = @tableName;
open c;
fetch c into @name;
while @@fetch_status = 0 begin
print 'name:' + @name;
fetch c into @name;
end
close c;
deallocate c;
end;
При работе: отображаетсяТриггеры/процедуры помогают
begin transaction
insert into course values('K1','data1','lund',5);
update course
set cname ='informatik';
commit
следующее сообщение:
inside trigger
(0 row(s) affected)
(1 row(s) affected)
inside trigger
(1 row(s) affected)
(1 row(s) affected)
В конце концов, почему 1 ряд пострадавших Показать 2 раза, в конце концов ?? Когда он только изменяет cname на «информационный» в одной позиции?
Это не вопрос Oracle как помеченный - что такое СУБД? –