-- @@@ START COPYRIGHT @@@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements.  See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership.  The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License.  You may obtain a copy of the License at
--
--   http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied.  See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
-- @@@ END COPYRIGHT @@@
-- EMBEDDED SQL/C test w/ Triggers on Update
-- runs on cat1.SCHM only
----------------------------------------

-- clean_up on all schemas
set schema CAT1.SCHM;
obey TEST_14_2(clean_up);
obey TEST_14_2(set_up);

-- start logging
log   LOG_14_2 clear;

set schema CAT1.SCHM;
obey TEST_14_2(tests);

log;

delete from tab1a;
delete from tab1b;
obey emb-env.sql;

log   LOG_14_2;
alter trigger disable trig2;
obey TEST_14_2(tests);


-- end logging
LOG;

-- cleanup 
obey TEST_14_2(clean_up);

exit;
----------------------------------------

?section clean_up
-------------------
SET SCHEMA cat1.schm;

obey clear.sql;

sh rm -f etest_14_2.cpp etest_14_2.exe etest_14_2.ilk etest_14_2.obj etest_14_2.pdb etest_14_2.lst etest_14_2.m;

?section set_up
-------------------

obey emb-env.sql;

-- define the triger

SET SCHEMA cat1.schm;


CREATE TRIGGER trig2
BEFORE UPDATE OF (c) ON tab1A 
REFERENCING NEW AS newR FOR EACH ROW
WHEN (newR.c <> 2*newR.a )
SET newR.c = 2*a;


-- make the executable

-- sh sh ./make-emb etest_14_2 | tee -a LOG_14_2;
sh sh ./makefileall.ksh etest_14_2 ${mxcmpdir} ${mxcidir} 2>&1;

?section tests
-------------------

log   LOG_14_2;
sh ./etest_14_2.exe | tee -a LOG_14_2;

