상세 컨텐츠

본문 제목

robotData

청강컴정/09DataBase기말고사

by luckey 2009. 6. 4. 19:04

본문

create table robotData
(
 idx  int primary key,
 title varchar(50) not null,
 sensor char(5) default '00000',
 buildLevel tinyint default 0,
 programLevel tinyint default 0,
 contents nvarchar(1000),
 visit int default 0,
 writeDate datetime default getdate()
)

create proc robotDataInsert
(
 @title varchar(50),
 @sensor char(5),
 @buildLevel tinyint,
 @programLevel tinyint,
 @contents nvarchar(1000)
)
as
begin
 insert into robotData(title, sensor, buildLevel, programLevel, contents)
 values (@title, @sensor, @buildLevel, @programLevel, @contents)
end


create trigger TRG_ROBOTDATA_INS
on robotData
instead of insert
as
begin
 set nocount on;
 begin tran
 begin try
  declare @getTitle varchar(50)
  declare @maxIdx int

  select @getTitle = erc_db.dbo.blankDelete(@title) from inserted
 end try
 begin catch
  if @@TRANCOUNT > 0
   ROLLBACK TRAN
 end catch

 if @@TRANCOUNT > 0
  COMMIT TRAN
end

관련글 더보기

댓글 영역