cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
create t1( a1 integer, a2 float, a3 char(20, 1) );
create t2( a1 integer, a2 float, a3 char(20, 1) );

create referential t1( a1, a2, a3 ) insert t2( a1, a2, a3);
create referential t2( a1, a2, a3 ) delete t1( a1, a2, a3);

insert into t2 set to 10, 10.00, 'first tuple';
insert into t2 set to 20, 20.00, 'second tuple';
insert into t2 set to 30, 30.00, 'third tuple';
insert into t2 set to 40, 40.00, 'fourth tuple';

insert into t1 set to 10, 10.00, 'first tuple';
insert into t1 set to 20, 20.00, 'second tuple';
insert into t1 set to 30, 30.00, 'third tuple';
insert into t1 set to 40, 40.00, 'fourth tuple';

insert into t1 set to 10, 10.00, null;
insert into t1 set to 20, 20.00, null;
insert into t1 set to 30, 30.00, null;
insert into t1 set to 40, 40.00, null;

insert into t1 set to 1000, 10.00, null;
insert into t1 set to 2000, 20.00, null;
insert into t1 set to 3000, 30.00, null;
insert into t1 set to 4000, 40.00, null;

select from t1;
select from t2;

delete from t2 where a1 = 40;
delete from t2 where a1 = 30;
delete from t2 where a1 = 20;
delete from t2 where a1 = 10;

select from t1;
select from t2;

delete from t1 where a1 = 40;
delete from t1 where a1 = 30;
delete from t1 where a1 = 20;
delete from t1 where a1 = 10;

select from t1;
select from t2;

insert into t2 set to 10, 10.00, null;
insert into t2 set to 20, 20.00, null;
insert into t2 set to 30, 30.00, null;
insert into t2 set to 40, 40.00, null;

select from t1;
select from t2;

delete from t2 where a1 = 10 and a2 = 10.00 and a3 = 'first tuple';
delete from t2 where a1 = 20 and a2 = 20.00 and a3 = 'second tuple';
delete from t2 where a1 = 30 and a2 = 30.00 and a3 = 'third tuple';
delete from t2 where a1 = 40 and a2 = 40.00 and a3 = 'fourth tuple';

select from t1;
select from t2;

create unique index on t2( a1, a2, a3 );

delete from t2 where a1 = 40;
delete from t2 where a1 = 30;
delete from t2 where a1 = 20;
delete from t2 where a1 = 10;

select from t1;
select from t2;

drop t1;
drop t2;

create ta( a1, a2, a3 );
create view v1 as select from ta;
create view v2 as select from v1;

create tn( a1, a2, a3 );
create view vm as select from tn;
create view vn as select from vm;

insert into tn set a1 = 1, a2 = 2, a3 = 3;

create refer v2 set a1 insert vn set a1;
create refer v1 set a2 insert vm set a2;
create refer ta (a3) insert tn(a3)

insert into v2 set a1= 1, a2 = 2, a3 = 4;
insert into v2 set a1= 1, a2 = 3, a3 = 3;
insert into v2 set a1= 2, a2 = 2, a3 = 3;

insert into v2 set a1= 1, a2 = 2, a3 = 3;

select from vn;
select from v2;

drop refer v2 set a1 insert vn set a1;
drop refer v1 set a2 insert vm set a2;
drop refer ta set a3 insert tn set a3;

create refer vn set a1 delete v2 set a1;
create refer vm set a2 delete v1 set a2;
create refer tn set a3 delete ta (a3		);

delete from vn where a1= 1 and  a2 = 2 and  a3 = 3;
update ta set a1 = 2;
delete from vn where a1= 1 and  a2 = 2 and  a3 = 3;
update ta set a2 = 3;
delete from vn where a1= 1 and  a2 = 2 and  a3 = 3;
update ta set a3 = 4;
delete from vn where a1= 1 and  a2 = 2 and  a3 = 3;

select from vn;
select from v2;

drop ta;
drop v2;
drop v1;

drop tn;
drop vm;
drop vn;
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* * * * * * * * * * * * * * * * * * * * * * * * * * *     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
* * 
*** Error: delete constraint violation, constraining table 't1'
* 
*** Error: delete constraint violation, constraining table 't1'
* 
*** Error: delete constraint violation, constraining table 't1'
* 
*** Error: delete constraint violation, constraining table 't1'
* *     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
* * 
*** Error: null(s) in index key value
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

* * * * * * * * * * * * * * * * * * * 
*** Error: insert constraint violation, constraining table 'tn'
* 
*** Error: insert constraint violation, constraining table 'vm'
* 
*** Error: insert constraint violation, constraining table 'vn'
* * * *     a1      a2      a3

     1       2       3
*     a1      a2      a3

     1       2       3
* * * * * * * * * * 
*** Error: delete constraint violation, constraining table 'v2'
* * 
*** Error: delete constraint violation, constraining table 'v1'
* * 
*** Error: delete constraint violation, constraining table 'ta'
* * * *     a1      a2      a3

*     a1      a2      a3

     2       3       4
* * * * * * * * * 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > stdout.jp_euc <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* * * * * * * * * * * * * * * * * * * * * * * * * * *     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
* * 
*** Error: ϰȿǤϰΥơ֥ 't1' Ǥ
* 
*** Error: ϰȿǤϰΥơ֥ 't1' Ǥ
* 
*** Error: ϰȿǤϰΥơ֥ 't1' Ǥ
* 
*** Error: ϰȿǤϰΥơ֥ 't1' Ǥ
* *     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01  first tuple
    20   2.000000e+01  second tuple
    30   3.000000e+01  third tuple
    40   4.000000e+01  fourth tuple
    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

    10   1.000000e+01
    20   2.000000e+01
    30   3.000000e+01
    40   4.000000e+01
* * 
*** Error: ǥḁ̊ͤǤ
* * * * * * *     a1             a2  a3

  1000   1.000000e+01
  2000   2.000000e+01
  3000   3.000000e+01
  4000   4.000000e+01
*     a1             a2  a3

* * * * * * * * * * * * * * * * * * * 
*** Error: ȿǤϰΥơ֥ 'tn' Ǥ
* 
*** Error: ȿǤϰΥơ֥ 'vm' Ǥ
* 
*** Error: ȿǤϰΥơ֥ 'vn' Ǥ
* * * *     a1      a2      a3

     1       2       3
*     a1      a2      a3

     1       2       3
* * * * * * * * * * 
*** Error: ϰȿǤϰΥơ֥ 'v2' Ǥ
* * 
*** Error: ϰȿǤϰΥơ֥ 'v1' Ǥ
* * 
*** Error: ϰȿǤϰΥơ֥ 'ta' Ǥ
* * * *     a1      a2      a3

*     a1      a2      a3

     2       3       4
* * * * * * * * * 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout.jp_euc
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Referential Constraints - constrained insertions and deletions.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
