-- -*-Sql-*- mode (to keep my emacs happy)
--
-- SQL script to create the trigger(s) enabling the load API for
-- SGLD_Chr_Map_Assocs.
--
-- Scaffold auto-generated by gen-api.pl.
--
--
-- $GNF: projects/gi/symgene/src/DB/load-trgs/Chr_Map_Assocs.trg,v 1.8 2003/05/23 17:42:28 hlapp Exp $
--

--
-- Copyright 2002-2003 Genomics Institute of the Novartis Research Foundation
-- Copyright 2002-2008 Hilmar Lapp
-- 
--  This file is part of BioSQL.
--
--  BioSQL is free software: you can redistribute it and/or modify it
--  under the terms of the GNU Lesser General Public License as
--  published by the Free Software Foundation, either version 3 of the
--  License, or (at your option) any later version.
--
--  BioSQL is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU Lesser General Public License for more details.
--
--  You should have received a copy of the GNU Lesser General Public License
--  along with BioSQL. If not, see <http://www.gnu.org/licenses/>.
--

CREATE OR REPLACE TRIGGER BIR_Chr_Map_Assocs
       INSTEAD OF INSERT
       ON SGLD_Chr_Map_Assocs
       REFERENCING NEW AS new OLD AS old
       FOR EACH ROW
DECLARE
	pk		SG_SEQFEATURE.OID%TYPE;
	do_DML		INTEGER DEFAULT BSStd.DML_I;
BEGIN
	-- add the new mapping
	pk := ChrEntA.get_Oid(
			EntSeg_Oid	      => :new.EntSeg_Oid,
			EntSeg_Start_Pos      => :new.EntSeg_Start_Pos,
			EntSeg_End_Pos	      => :new.EntSeg_End_Pos,
			EntSeg_Num	      => :new.EntSeg_Num,
			EntSeg_Type_Name      => :new.FType_Name,
			EntSeg_Source_Name    => :new.FSrc_Name,
			ChrSeg_Oid	      => :new.ChrSeg_Oid,
			ChrSeg_Start_Pos      => :new.ChrSeg_Start_Pos,
			ChrSeg_End_Pos	      => :new.ChrSeg_End_Pos,
			ChrSeg_Strand	      => :new.ChrSeg_Strand,
			ChrSeg_Pct_Identity   => :new.ChrSeg_Pct_Identity,
			Ent_Oid		      => :new.Ent_Oid,
			Ent_Accession	      => :new.Ent_Accession,
			Ent_Identifier	      => :new.Ent_Identifier,
			Ent_Version	      => :new.Ent_Version,
			DB_Oid		      => :new.DB_Oid,
			DB_Name		      => :new.DB_Name,
			DB_Acronym	      => :new.DB_Acronym,
			Ent_Tax_Oid	      => :new.Ent_Tax_Oid,
			Ent_Tax_Name	      => :new.Ent_Tax_Name,
			Ent_Tax_NCBI_Taxon_ID => :new.Ent_Tax_NCBI_Taxon_ID,
			Chr_Oid		      => :new.Chr_Oid,
			Chr_Name	      => :new.Chr_Name,
			Chr_Accession	      => :new.Chr_Accession,
			Asm_Oid		      => :new.Asm_Oid,
			Asm_Name	      => :new.Asm_Name,
			Asm_Acronym	      => :new.Asm_Acronym,
			Chr_Tax_Oid	      => :new.Asm_Tax_Oid,
			Chr_Tax_Name	      => :new.Asm_Tax_Name,
			Chr_Tax_NCBI_Taxon_ID => :new.Asm_Tax_NCBI_Taxon_ID,
			do_DML		      => do_DML);
END;
/
