-- @@@ 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 @@@
-- semantics
-- clustering key

obey TEST_1_1_1_12(clean_up);
obey TEST_1_1_1_12(set_up);
log   LOG_1_1_1_12 clear;
obey TEST_1_1_1_12(tests);
LOG;
obey TEST_1_1_1_12(clean_up);
exit;

?section clean_up
set schema CAT1.SCHM;
 
drop trigger t20ur;
drop table t20;
drop  table t20_logger;

?section set_up
SET SCHEMA cat1.schm;
create table t20 
	(a int not null, 
	 b int not null, 
	 c int not null, 
	 d int not null) 
	store by (a,c) no partition;

create table t20_logger
	(op char(10),
	type char(10),
	oldval int,
	newval int);

CREATE TRIGGER T20UR AFTER UPDATE ON T20 
	REFERENCING NEW AS MY_NEW, OLD AS MY_OLD 
	FOR EACH ROW 
	INSERT INTO T20_LOGGER VALUES  ('Update', 
					'Row', 
					MY_OLD.B, 
					MY_NEW.B);

insert into t20 values(1,2,3,4);
insert into t20 values(2,3,4,5);
insert into t20 values(3,4,5,6);


?section tests

--------------------------------------------------------
-- TEST CASE
--------------------------------------------------------
UPDATE T20 SET B=B+10;

select * from t20 order by a; -- check results
select * from t20_logger order by op,oldval; -- check results

--------------------------------------------------------
