-- @@@ 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 Delete
-- runs on cat1.SCHM only
----------------------------------------

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

-- start logging
log   LOG_14_6 clear;

set schema CAT1.SCHM;
obey TEST_14_6(tests);
log;

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

log   LOG_14_6;

alter trigger disable trig12;
obey TEST_14_6(tests);


-- end logging
LOG;

-- cleanup 
obey TEST_14_6(clean_up);

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

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

obey clear.sql;

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


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

obey emb-env.sql;


-- defining trig12

SET SCHEMA cat1.schm;

CREATE TRIGGER trig12
BEFORE DELETE ON tab1A 
REFERENCING OLD as oldR
FOR EACH ROW
WHEN (oldR.a between 3 and 4)
SIGNAL SQLSTATE 's9999' ('trig12 signaled');


-- make the executable

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


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

log   LOG_14_6;
sh ./etest_14_6.exe | tee -a LOG_14_6;


