-- Licensed Materials - Property of IBM
--
-- BI and PM: CM
--
-- (C) Copyright IBM Corp. 2008, 2009
--
-- US Government Users Restricted Rights - Use, duplication or disclosure
-- restricted by GSA ADP Schedule Contract with IBM Corp.

-- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
-- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).


--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
create index IDX_CREATED on CMOBJECTS(CREATED);

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
!AddPISQL "drop index IDX_CMUNIQUENAMES_CMID" "ignoreErrors"

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
drop table CMUNIQUENAMES;

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
drop table CMTMPDELNAMES;

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
drop trigger CMOBJECTS_ONMOVE_TR;

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
drop trigger CMOBJECTS_ONDELETE_TR;

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
create or replace trigger CMOBJNAMES_INSORUPD_TR  instead of insert on CMOBJNAMES 
begin
	update CMOBJNAMES_BASE set NAME=:new.NAME, MAPDLOCALEID=:new.MAPDLOCALEID where CMID=:new.CMID and LOCALEID=:new.LOCALEID;
	if	(sql%rowcount = 0) then
		insert into CMOBJNAMES_BASE (CMID, LOCALEID, NAME, MAPDLOCALEID, ISDEFAULT) values (:new.CMID, :new.LOCALEID, :new.NAME, :new.MAPDLOCALEID, :new.ISDEFAULT);
	end if;
end;
/

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
drop trigger CMOBJNAMES_HELPER_TR;

--CMSCRIPT_UPGRADE_SKIP_COMMAND(3.0068,4.0001)
drop procedure CMRECONCILE_NAMES;