日期:2014-05-18  浏览次数:20807 次

Oracle触发器 急!!!!!
下面是我在sql中写好的触发器,因为没写过oracle的,大家帮忙看下,在oracle里这个该怎么写
alter trigger TongJi_Report
on study
for update
as
declare
  @str_StudyInstanceUID varchar(120),
  @str_ReportStatus varchar(10),
  @str_AccessionNumber varchar(120),
  @str_PatientNameC varchar(10),
  @str_PatientID varchar(64),
  @str_PatientSex varchar(10),
  @str_PatientBirthday datetime,
  @str_StudyClass2 varchar(50),
  @str_SeriesDate datetime,
  @str_laiyuan varchar(10),
  @str_RECEIVED_CODE varchar(50),
  @str_shenqingYiShi varchar(50),
  @str_ReportingPhysician varchar(50),
  @str_FactPrice varchar(50),
  @str_InsuranceType varchar(50),
  @str_jianchasuojian varchar(4000),
  @str_jianchajielun varchar(4000),
  @str_ReportFileLocate varchar(120),
  @str_ReportFileName varchar(120)
   
if update(ReportStatus)

  select @str_StudyInstanceUID=StudyInstanceUID,@str_ReportStatus=ReportStatus from inserted

select @str_PatientID=PatientID,@str_PatientNameC=PatientNameC,@str_PatientSex=PatientSex,@str_PatientBirthday=PatientBirthday,@str_AccessionNumber=AccessionNumber,
@str_StudyClass2=StudyClass2,@str_SeriesDate=SeriesDate,@str_laiyuan=laiyuan,@str_RECEIVED_CODE=RECEIVED_CODE,
@str_shenqingYiShi=shenqingYiShi,@str_ReportingPhysician=ReportingPhysician,@str_FactPrice=FactPrice,
@str_InsuranceType=InsuranceType,@str_jianchasuojian=study.jianchasuojian,@str_jianchajielun=study.jianchajielun,
@str_ReportFileLocate=StudyComponent.ReportFileLocate,@str_ReportFileName=StudyComponent.ReportFileName
from Patient,Study,Series,StudyComponent where Patient.PatientUID=study.PatientUID and
Study.StudyInstanceUID=Series.StudyInstanceUID and Series.StudyInstanceUID=StudyComponent.StudyInstanceUID and
Study.StudyInstanceUID =@str_StudyInstanceUID and studycomponent.reportfiletype='jpg'

if(@str_ReportStatus=8 and @str_laiyuan='门诊' and @str_AccessionNumber is not null and @str_AccessionNumber<>'')
begin
  if @str_StudyInstanceUID is null
  begin
  select @str_StudyInstanceUID=''
  end 
  if @str_ReportStatus is null
  begin
  select @str_ReportStatus=''
  end  
  if @str_AccessionNumber is null
  begin
  select @str_AccessionNumber=''
  end
  if @str_PatientNameC is null
  begin
  select @str_PatientNameC=''
  end 
  if @str_PatientSex is null
  begin
  select @str_PatientSex=''
  end 
  if @str_PatientBirthday is null
  begin
  select @str_PatientBirthday=getdate()
  end 
  if @str_StudyClass2 is null
  begin
  select @str_StudyClass2=''
  end 
  if @str_SeriesDate is null
  begin
  select @str_SeriesDate=getdate()
  end 
  if @str_laiyuan is null
  begin
  select @str_laiyuan=''
  end 
  if @str_RECEIVED_CODE is null
  begin
  select @str_RECEIVED_CODE=''
  end 
  if @str_shenqingYiShi is null
  begin
  select @str_shenqingYiShi=''
  end 
  if @str_ReportingPhysician is nu