[Bio] / BioSimScratch / TriggerCatalog.sql Repository:
ViewVC logotype

View of /BioSimScratch/TriggerCatalog.sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (annotate)
Fri Apr 2 21:34:01 2004 UTC (15 years, 6 months ago) by park
Branch: MAIN
CVS Tags: post-st-migration2, mass-spec-01, sc2004-3, mass-spec-02, post-st-migration, forRick-14Jul04-1, forRick-14Jul04-0, sc2004-4, sc04-finalDay, sc2004-2, sc2004-1, sc2004-0, HEAD
Changes since 1.2: +2 -2 lines
        update table name in the  trigger, KAHBIR_CATDIRENTVERSIONS_TRG

-- ------------------------------------------------------------------  
--      Constaint for uniquely existence true(1)  for a DefaultVer field 
--      under the given  CatDirEntId
--      from the CatDirEntVersions table.

--      Naming Conversions: 
--	"KahXXX_TableName_TRG"
--        Kah stands for an  entire architecture domain name.
--	The firs X is either A or B for After or Before.
--	The second X states the actitivity I, U, D, S for Insert,
--	     Update, Delete, or Select.
--        The third X is either S or R for Statement or Row.
--        Sequences names will be suffixed with "_TRG".   
-- ---------------------------------------------------------------------

create or replace trigger KahBIR_CatDirEntVersions_TRG
before  insert  ON KAHCatDirEntVersions
FOR EACh ROW
declare
  
   kcountDefault  number;
   kount_out_of_error  EXCEPTION;

  begin
    select count(DefaultVer) into kcountDefault  from KAHCatDirEntVersions
    where DefaultVer = 1 and  CatDirEntId = :new.CatDirEntId;

    if ((kcountDefault = 1) and (:new.DefaultVer = 1)) then
      RAISE  kount_out_of_error ;
    end if;
    
    exception
      when  kount_out_of_error   then
         Raise_application_error (-20500, 'There already exist a default version!');
end;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3