-- @@@ 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 @@@
-- Compound CREATE SCHEMA statement (incl. triggers) 

obey TEST_1_1_1_13(clean_up);
obey TEST_1_1_1_13(set_up);
log   LOG_1_1_1_13 clear;
obey TEST_1_1_1_13(tests);
log;
obey TEST_1_1_1_13(clean_up);
exit;

?section clean_up
set schema CAT1.SCHM;

drop trigger test_schema.trg1;
drop trigger test_schema.trg2;
drop table   t11113;
drop table   test_schema.t1;
drop table   test_schema.t2;
drop schema  test_schema;

?section set_up
set schema CAT1.SCHM;

create table t11113 (i int, j int);

?section tests

set schema CAT1.SCHM;

create schema test_schema ;

--Caroline: correct scripting errors 
set schema cat1.test_schema ;

create table t1 (x int, y int);
create table t2 like t1 ;

create trigger trg1 after insert on t1
    referencing new as mynew
      insert into t2 select * from mynew ;

create trigger trg2 before update of (j) on cat1.schm.t11113
    referencing new as myrow
      set myrow.i = (select MAX(x) from t2);

showddl cat1.test_schema.t1;

showddl schm.t11113;

