blob: f963a1258ba7c0ec9f26fc8ae04db890bbece084 [file] [log] [blame]
ij> --
-- 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.
--
-- #########################################################################
--- some Test cases from IBM DB2. Reusing them to test Cloudscape
-- # MODIFIED BY : WHO WHEN WHY
-- # : ----------- ------- -------------------------------
-- # : P. Selinger 950128 new testcase
-- # : M. Snowbell 970716 beef up for better MPP coverage
-- # : - add first column for partition
-- # : - add rows
-- # : Suresh T 020616 - Modified for Cloudscape
-- # : Mark C 040309 - Modified for DB2 Cloudscape
-- #########################################################################
-- # TEST CASE : cself301.sql
-- # LINE ITEM : Self-referencing subqueries
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases where of delete statements
-- # : where the deleted table also appears in a
-- # : subquery that qualifies which rows are changed
-- # : and the deleted table has a self-ref'g RI const.
-- *************************************************************************
create schema db2test;
0 rows inserted/updated/deleted
ij> set schema db2test;
0 rows inserted/updated/deleted
ij> -- "START OF TESTCASE: cself301.sql";
autocommit off;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp on delete
cascade, dno char(3) references db2test.dept on delete
set null);
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.origemp on delete
cascade, dno char(3) references db2test.origdept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- "END OF TESTUNIT: 01";
-- *************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on same table on RI cascade col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.emp where name in (select name from db2test.emp
where mgrname = 'JOHN') order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> delete from db2test.emp where name in (select name from db2test.emp
where mgrname = 'JOHN');
2 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> -- "END OF TESTUNIT: 02";
-- *************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : delete with 2 levels of SQ and self-ref in 2nd
-- : correlated to 1st SQ on foreign key
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.emp;
10 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp where dno in (select dno from db2test.dept D
where D.dno in (select dno from db2test.emp E where E.dno = D.dno
and e.mgrname = 'JOHN')) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in (select dno from db2test.dept D
where D.dno in (select dno from db2test.emp E where E.dno = D.dno
and e.mgrname = 'JOHN'));
10 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> -- "END OF TESTUNIT: 03";
-- *************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : delete with SQ GB Having SQ on
-- : modified table
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.emp;
10 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from db2test.emp
where mgrname = 'ASHOK')) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from db2test.emp
where mgrname = 'ASHOK'));
20 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> -- "END OF TESTUNIT: 04";
-- *************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : delete with SQ GB Having SQ on
-- : modified table -- 3 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from
db2test.dept D where dno in (select dno from db2test.emp E2
where D. dno = E2.dno))) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from
db2test.dept D where dno in (select dno from db2test.emp E2
where D. dno = E2.dno)));
20 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> -- "END OF TESTUNIT: 05";
-- *************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : delete on view with SQ GB Having SQ on
-- : modified table -- 3 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> create view db2test.vemp (vc0, vname, vmgrname, vdno) as
select * from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from
db2test.dept D where dno in (select dno from db2test.emp E2
where D. dno = E2.dno)));
0 rows inserted/updated/deleted
ij> select * from db2test.vemp order by 2, 3, 4;
VC0 |VNAME |VMGRNAME |VDNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> delete from db2test.vemp;
ERROR 42Y24: View 'DB2TEST.VEMP' is not updatable. (Views are currently not updatable.)
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 06";
-- "cleanup";
drop view db2test.vemp;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> --
rollback;
ij> -- #########################################################################
-- # TESTCASE NAME : cself302.sql
-- # LINE ITEM : Self-referencing subqueries
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases of delete statements
-- # : where the deleted table is connected to other
-- # : tables in the query by cascade on delete.
-- # : shape of the RI tree is a 1 level star fanout.
-- #########################################################################
-- "START OF TESTCASE: cself302.sql";
autocommit off;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> create table db2test.secondemp (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp on delete cascade,
dno char(3) references db2test.origdept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 01";
-- *************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on same table on RI cascade col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.dept where dno in (select dno from db2test.emp
where mgrname = 'JOHN') order by 2,3;
C0 |DNO|DNAME
--------------------------
1 |K55|DB
ij> delete from db2test.dept where dno in (select dno from db2test.emp
where mgrname = 'JOHN');
1 row inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> -- "END OF TESTUNIT: 02";
-- *************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : delete with 2 levels of SQ and self-ref in 2nd
-- : correlated to 1st SQ on foreign key
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.emp;
10 rows inserted/updated/deleted
ij> delete from db2test.dept;
2 rows inserted/updated/deleted
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept where dno in (select dno from
db2test.secondemp E
where E.dno in (select dno from db2test.emp D where E.dno = D.dno
and D.dno = 'K55')) order by 2, 3;
C0 |DNO|DNAME
--------------------------
1 |K55|DB
ij> delete from db2test.dept where dno in (select dno
from db2test.secondemp E
where E.dno in (select dno from db2test.emp D where E.dno = D.dno
and D.dno = 'K55'));
1 row inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> -- "END OF TESTUNIT: 03";
-- *************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : delete with SQ GB Having SQ on
-- : child table
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.emp;
10 rows inserted/updated/deleted
ij> delete from db2test.dept;
2 rows inserted/updated/deleted
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept where exists ( select max(mgrname) from
db2test.secondemp group by dno having dno in (select dno from
db2test.emp where mgrname = 'ASHOK')) order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists ( select max(mgrname) from
db2test.secondemp group by dno having dno in (select dno from
db2test.emp where mgrname = 'ASHOK'));
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
ij> -- "END OF TESTUNIT: 04";
-- *************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : above -- 7 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept dtop where exists
(select * from db2test.secondemp where exists
(select dno from
db2test.dept D1 where dno = dtop.dno and dno in
(select dno from db2test.emp E2 where D1.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno and dno in
(select dno from db2test.emp E4 where E3.dno = E4.dno and dno in
(select dno from db2test.emp E5 where E4.dno = E5.dno and dno in
(select dno from db2test.emp E6 where E5.dno = E6.dno)
)))))) order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> -- begin RJC950405 (commented out and added ; to the following line as I think we're fixed?)
-- -- testcase commented out pending defect fix;
-- end RJC950405
delete from db2test.dept where exists
(select * from db2test.secondemp where exists
(select dno from
db2test.dept D1 where dno = db2test.dept.dno and dno in
(select dno from db2test.emp E2 where D1.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno and dno in
(select dno from db2test.emp E4 where E3.dno = E4.dno and dno in
(select dno from db2test.emp E5 where E4.dno = E5.dno and dno in
(select dno from db2test.emp E6 where E5.dno = E6.dno)
))))));
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
ij> -- "END OF TESTUNIT: 05";
-- *************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : on second child table, delete cascade on each
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> -- create a second child table like emp
create table db2test.emp2 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept dtop where exists
(select dno from db2test.emp2 E2 where Dtop.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno))
order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists
(select dno from db2test.emp2 E2 where db2test.dept.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno));
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> -- "END OF TESTUNIT: 06";
-- *************************************************************************
-- TESTUNIT : 07
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : on second child table, delete cascade on each
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 07";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept dtop where exists
(select dno from db2test.emp2 E2 where dtop.dno = E2.dno)
and exists
(select dno from db2test.emp E3 where dtop.dno = E3.dno)
order by 2,3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists
(select dno from db2test.emp2 E2 where db2test.dept.dno = E2.dno)
and exists
(select dno from db2test.emp E3 where db2test.dept.dno = E3.dno);
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> -- "END OF TESTUNIT: 07";
-- *************************************************************************
-- TESTUNIT : 08
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : on second child table, delete cascade on each
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 08";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept dtop where exists
(select dno from db2test.emp2 E2 where dtop.dno = E2.dno)
or exists
(select dno from db2test.emp E3 where dtop.dno = E3.dno)
order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists
(select dno from db2test.emp2 E2 where db2test.dept.dno = E2.dno)
or exists
(select dno from db2test.emp E3 where db2test.dept.dno = E3.dno);
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> -- "END OF TESTUNIT: 08";
-- *************************************************************************
-- TESTUNIT : 09
-- DESCRIPTION : delete on view with SQ GB Having SQ on
-- : modified table -- 3 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 09";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> create view db2test.vempjoin (vname1, vname2, vmgrname, vdno) as
select e.name, e2.name, e.mgrname, e.dno
from db2test.emp e, db2test.emp2 e2
where e.dno = e2.dno;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52') order by 2, 3;
C0 |DNO|DNAME
--------------------------
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> -- "END OF TESTUNIT: 09";
-- *************************************************************************
-- TESTUNIT : 10
-- DESCRIPTION : delete on iudt where SQ on
-- : view with join on 15 child tables
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 10";
-- reset to original rows
delete from db2test.emp;
5 rows inserted/updated/deleted
ij> delete from db2test.emp2;
5 rows inserted/updated/deleted
ij> delete from db2test.dept;
1 row inserted/updated/deleted
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> -- create a third child table like emp
create table db2test.emp3 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 4th child table like emp
create table db2test.emp4 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 5th child table like emp
create table db2test.emp5 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 6th child table like emp
create table db2test.emp6 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 7th child table like emp
create table db2test.emp7 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp7 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 8th child table like emp
create table db2test.emp8 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp8 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 9th child table like emp
create table db2test.emp9 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp9 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 10th child table like emp
create table db2test.emp10 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp10 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 11th child table like emp
create table db2test.emp11 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp11 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 12th child table like emp
create table db2test.emp12 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp12 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 13th child table like emp
create table db2test.emp13 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp13 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 14th child table like emp
create table db2test.emp14 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp14 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 15th child table like emp
create table db2test.emp15 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete cascade,
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp15 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> create view db2test.vempjoin12 (vname1, vname2, vname3, vname4, vname5,
vname6, vname7, vname8, vname9, vname10, vname11, vname12,
vmgrname, vdno) as
select e.name, e2.name, e3.name, e4.name, e5.name, e6.name, e7.name,
e8.name, e9.name, e10.name, e11.name, e12.name,
e.mgrname, e.dno
from db2test.emp e, db2test.emp2 e2, db2test.emp3 e3, db2test.emp4 e4,
db2test.emp5 e5, db2test.emp6 e6, db2test.emp7 e7, db2test.emp8 e8,
db2test.emp9 e9, db2test.emp10 e10, db2test.emp11 e11,
db2test.emp12 e12
where e.dno = e2.dno
and e.dno = e2.dno
and e.dno = e2.dno
and e.dno = e3.dno
and e.dno = e4.dno
and e.dno = e5.dno
and e.dno = e6.dno
and e.dno = e7.dno
and e.dno = e8.dno
and e.dno = e9.dno
and e.dno = e10.dno
and e.dno = e11.dno
and e.dno = e12.dno;
0 rows inserted/updated/deleted
ij> commit;
ij> -- FOLLOWING TWO QUERIES HANG IN DERBY NOW ..
-- UNCOMMENT once they pass.
-- select * from db2test.dept where dno in (select vdno from
-- db2test.vempjoin12)
-- and dno in ('K55', 'K52') order by 2, 3;
--delete from db2test.dept where dno in (select vdno from
-- db2test.vempjoin12)
-- and dno in ('K55', 'K52');
select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp6 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp7 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp8 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp9 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp10 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp11 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp12 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp13 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp14 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp15 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 10";
-- *************************************************************************
-- TESTUNIT : 11
-- DESCRIPTION : delete with many SQ levels correl'd on child tables
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 11";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp6;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp7;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp8;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp9;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp10;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp11;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp12;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp13;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp14;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp15;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp7 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp8 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp9 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp10 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp11 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp12 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp13 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp14 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp15 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept d where
dno in (select dno from db2test.emp e where
e.dno = d.dno and e.dno in (select dno from db2test.emp2 e2 where
e2.dno = e.dno and e2.dno in (select dno from db2test.emp3 e3 where
e3.dno = e2.dno and e3.dno in (select dno from db2test.emp4 e4 where
e4.dno = e3.dno and e4.dno in (select dno from db2test.emp5 e5 where
e5.dno = e4.dno and e5.dno in (select dno from db2test.emp6 e6 where
e6.dno = e5.dno and e6.dno in ('K55', 'K52')))))))
order by 2, 3;
C0 |DNO|DNAME
--------------------------
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where
dno in (select dno from db2test.emp e where
e.dno = db2test.dept.dno and e.dno in (select dno from db2test.emp2 e2 where
e2.dno = e.dno and e2.dno in (select dno from db2test.emp3 e3 where
e3.dno = e2.dno and e3.dno in (select dno from db2test.emp4 e4 where
e4.dno = e3.dno and e4.dno in (select dno from db2test.emp5 e5 where
e5.dno = e4.dno and e5.dno in (select dno from db2test.emp6 e6 where
e6.dno = e5.dno and e6.dno in ('K55', 'K52')))))));
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp6 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp7 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp8 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp9 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp10 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp11 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp12 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp13 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp14 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp15 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> -- "END OF TESTUNIT: 11";
-- *************************************************************************
-- TESTUNIT : 12
-- DESCRIPTION : delete on view with union of 15 child tables
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 12";
-- reset to original rows
delete from db2test.dept;
1 row inserted/updated/deleted
ij> delete from db2test.secondemp;
1 row inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp6;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp7;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp8;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp9;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp10;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp11;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp12;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp13;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp14;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp15;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp7 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp8 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp9 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp10 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp11 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp12 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp13 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp14 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp15 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> create view db2test.vempunion15 (vname,
vmgrname, vdno) as
(select e.name, e.mgrname, e.dno
from db2test.emp e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp2 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp3 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp4 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp5 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp6 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp7 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp8 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp9 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp10 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp11 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp12 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp13 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp14 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp15 e);
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept where dno in
(select vdno from db2test.vempunion15)
and dno in ('K55', 'K52') order by 1, 2;
C0 |DNO|DNAME
--------------------------
1 |K55|DB
2 |K52|OFC
ij> delete from db2test.dept where dno in
(select vdno from db2test.vempunion15)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp6 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp7 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp8 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp9 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp10 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp11 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp12 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp13 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp14 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp15 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> -- "END OF TESTUNIT: 12";
-- "cleanup";
drop view VEMPUNION15;
0 rows inserted/updated/deleted
ij> drop view VEMPJOIN12;
0 rows inserted/updated/deleted
ij> drop view VEMPJOIN;
0 rows inserted/updated/deleted
ij> drop table db2test.emp15;
0 rows inserted/updated/deleted
ij> drop table db2test.emp14;
0 rows inserted/updated/deleted
ij> drop table db2test.emp13;
0 rows inserted/updated/deleted
ij> drop table db2test.emp12;
0 rows inserted/updated/deleted
ij> drop table db2test.emp11;
0 rows inserted/updated/deleted
ij> drop table db2test.emp10;
0 rows inserted/updated/deleted
ij> drop table db2test.emp9;
0 rows inserted/updated/deleted
ij> drop table db2test.emp8;
0 rows inserted/updated/deleted
ij> drop table db2test.emp7;
0 rows inserted/updated/deleted
ij> drop table db2test.emp6;
0 rows inserted/updated/deleted
ij> drop table db2test.emp5;
0 rows inserted/updated/deleted
ij> drop table db2test.emp4;
0 rows inserted/updated/deleted
ij> drop table db2test.emp3;
0 rows inserted/updated/deleted
ij> drop table db2test.emp2;
0 rows inserted/updated/deleted
ij> drop table db2test.secondemp;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "cself302.sql ENDED";
-- #########################################################################
-- # TESTCASE NAME : cself303.sql
-- # LINE ITEM : Self-referencing subqueries
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases where of delete statements
-- # : where the deleted table is connected to other
-- # : tables in the query by cascade on delete.
-- # : shape of the RI tree is a 6 level chain.
-- #########################################################################
-- "START OF TESTCASE: cself303.sql";
autocommit off;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a second child table like emp
create table db2test.emp2 (c0 int, name char(10) not null primary key
references db2test.emp on delete cascade,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a third child table like emp
create table db2test.emp3 (c0 int, name char(10) not null primary key
references db2test.emp on delete cascade,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 4th child table like emp
create table db2test.emp4 (c0 int, name char(10) not null primary key
references db2test.emp on delete cascade,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 5th child table like emp
create table db2test.emp5 (c0 int, name char(10) not null primary key
references db2test.emp on delete cascade,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 6th child table like emp
create table db2test.emp6 (c0 int, name char(10) not null primary key
references db2test.emp on delete cascade,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- "END OF TESTUNIT: 01";
-- *************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on child table on RI cascade col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.emp e where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN' and e3.mgrname = e2.mgrname)) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN' and e3.mgrname = e2.mgrname));
10 rows inserted/updated/deleted
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> -- "END OF TESTUNIT: 02";
-- *************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : delete where SQ on child table on RI cascade col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN')) order by 2,3,4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN'));
10 rows inserted/updated/deleted
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> -- "END OF TESTUNIT: 03";
-- *************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e5.name = e4.mgrname and e4.dno in
(select dno from db2test.emp3 e3 where e4.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e3.name = e2.mgrname and
e2.dno in (select dno from db2test.emp e1
where e1.name = e.mgrname and e1.mgrname = 'JOHN')))))
order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e5.name = e4.mgrname and e4.dno in
(select dno from db2test.emp3 e3 where e4.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e3.name = e2.mgrname and
e2.dno in (select dno from db2test.emp e1
where e1.name = db2test.emp.mgrname and
e1.mgrname = 'JOHN')))));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 04";
-- *************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> --FOLLOWING TWO QUERIES are giving syntax errors currently
--select * from db2test.emp e
-- where dno in (select dno from db2test.emp5 e5
-- where e5.dno in (select dno from db2test.emp4 e4 where
-- e5.name = e4.mgrname group by dno having dno in
-- (select dno from db2test.emp3 e3 where e4.dno = e3.dno and
-- e3.dno in (select dno from db2test.emp2 e2
-- where e3.name = e2.mgrname group by dno having
-- e2.dno in (select dno from db2test.emp e1
-- where e1.mgrname = e.mgrname and
-- e1.mgrname = 'JOHN'))))) order by 2, 3, 4;
-- delete from db2test.emp
-- where dno in (select dno from db2test.emp5 e5
-- where e5.dno in (select dno from db2test.emp4 e4 where
-- e5.name = e4.mgrname group by dno having dno in
-- (select dno from db2test.emp3 e3 where e4.dno = e3.dno and
-- e3.dno in (select dno from db2test.emp2 e2
-- where e3.name = e2.mgrname group by dno having
-- e2.dno in (select dno from db2test.emp e1
-- where e1.mgrname = e.mgrname and
-- e1.mgrname = 'JOHN')))));
select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 05";
-- *************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having, correl to iudt
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
db2test.emp.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e.mgrname = e2.mgrname group by dno having
e2.dno in (select dno from db2test.emp e1
where db2test.emp.mgrname = 'JOHN'))))) order by 2,3,4;
ERROR 42X04: Column 'DB2TEST.EMP.NAME' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'DB2TEST.EMP.NAME' is not a column in the target table.
ij> delete from db2test.emp
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
db2test.emp.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where db2test.emp.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e.mgrname = e2.mgrname group by dno having
e2.dno in (select dno from db2test.emp e1
where e.mgrname = 'JOHN')))));
ERROR 42X04: Column 'E.MGRNAME' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'E.MGRNAME' is not a column in the target table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 06";
-- *************************************************************************
-- TESTUNIT : 07
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having, correl to grandparent
-- EXPECTED RESULTS : SQL commands should get error -119
-- *************************************************************************
-- "START OF TESTUNIT: 07";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.dno = e2.dno group by dno having
e2.dno in (select dno from db2test.emp e1
where e.mgrname = 'JOHN'))))) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> delete from db2test.emp
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
db2test.emp.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.dno = e2.dno group by dno having
e2.dno in (select dno from db2test.emp e1
where db2test.emp.mgrname = 'JOHN')))));
2 rows inserted/updated/deleted
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 07";
-- *************************************************************************
-- TESTUNIT : 08
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having, correl to grandparent
-- EXPECTED RESULTS : select should get -119, delete should get ???
-- *************************************************************************
-- "START OF TESTUNIT: 08";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.name = e2.mgrname group by dno having
e2.dno in (select dno from db2test.emp e1
where e.mgrname = 'JOHN'))))) order by 2, 3, 4;
ERROR 42X24: Column E4.NAME is referenced in the HAVING clause but is not in the GROUP BY list.
ij> -- select should get -119;
delete from db2test.emp
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
db2test.emp.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.name = e2.mgrname group by dno having
e2.dno in (select dno from db2test.emp e1
where db2test.emp.mgrname = 'JOHN')))));
ERROR 42X24: Column E4.NAME is referenced in the HAVING clause but is not in the GROUP BY list.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 08";
-- *************************************************************************
-- TESTUNIT : 09
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having, correl to grandparent
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 09";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp3;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp4;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp5;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.dno = e2.dno group by dno having
e2.dno in (select dno from db2test.emp e1
where e.mgrname = 'JOHN'))))) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> delete from db2test.emp
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
db2test.emp.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.dno = e2.dno group by dno having
e2.dno in (select dno from db2test.emp e1
where e.mgrname = 'JOHN')))));
ERROR 42X04: Column 'E.MGRNAME' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'E.MGRNAME' is not a column in the target table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 09";
-- "cleanup";
drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.emp6;
0 rows inserted/updated/deleted
ij> drop table db2test.emp5;
0 rows inserted/updated/deleted
ij> drop table db2test.emp4;
0 rows inserted/updated/deleted
ij> drop table db2test.emp3;
0 rows inserted/updated/deleted
ij> drop table db2test.emp2;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> rollback;
ij> -- "cself303.clp ENDED";
-- #########################################################################
-- # TESTCASE NAME : cself304.sql
-- # LINE ITEM : Self-referencing subqueries
-- # COMPONENT(S) : SQN and SQR
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases where of delete statements
-- # : where the deleted table is connected to other
-- # : tables in the query by cascade on delete.
-- # : shape of the RI tree is a 3-way cycle to parent
-- #########################################################################
-- "START OF TESTCASE: cself304.sql";
autocommit off ;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10), dmgrname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10), dmgrname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB', 'JOHN');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC', 'ROBIN');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS', 'ASHOK');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3) references db2test.dept
on delete cascade );
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a second child table like emp
create table db2test.emp2 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp on delete cascade,
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete cascade;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 01";
-- ************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on child table on RI cascade col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.emp e where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where dmgrname = 'JOHN'));
C0 |NAME |MGRNAME |DNO
--------------------------------------
6 |HAMID |JOHN |K55
7 |TRUONG |HAMID |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
10 |BOBBIE |HAMID |K55
16 |GUY |JOHN |K55
17 |DON |GUY |K55
18 |MONICA |GUY |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
ij> delete from db2test.emp where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where dmgrname = 'JOHN'));
10 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 02";
-- ************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : same as 02, but with correlation to top table
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete cascade;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where d.dmgrname = 'john' and e2.name = d.dmgrname));
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where mgrname = 'john' and e2.name = d.dmgrname));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 03";
-- ************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : same as 02 but SQ's reversed
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete cascade;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in
(select dno from db2test.dept d
where d.dno in
(select dno from db2test.emp2 e2
where e2.mgrname = 'JOHN')) order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in
(select dno from db2test.dept d
where d.dno in
(select dno from db2test.emp2 e2
where e2.mgrname = 'JOHN'));
10 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 04";
-- ************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : same as 03 but SQ's reversed
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete cascade;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in
(select dno from db2test.dept d
where d.dno = e.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'JOHN')) order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in
(select dno from db2test.dept d
where d.dno = db2test.emp.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'JOHN'));
10 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 05";
-- ************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : same as 05 but extra table
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete cascade;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in
(select dno from db2test.origdept where dno in
(select dno from db2test.dept d
where d.dno = e.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'JOHN'))) order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in
(select dno from db2test.origdept where dno in
(select dno from db2test.dept d
where d.dno = db2test.emp.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'JOHN')));
10 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 06";
-- *************************************************************************
-- TESTUNIT : 07
-- DESCRIPTION : delete on parent with SQ on join view of children
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 07";
-- reset to original rows
delete from db2test.emp;
10 rows inserted/updated/deleted
ij> delete from db2test.emp2;
1 row inserted/updated/deleted
ij> delete from db2test.dept;
3 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete cascade;
0 rows inserted/updated/deleted
ij> commit;
ij> create view db2test.vempjoin (vname1, vname2, vmgrname, vdno) as
select e.name, e2.name, e.mgrname, e.dno
from db2test.emp e, db2test.emp2 e2
where e.dno = e2.dno;
0 rows inserted/updated/deleted
ij> select * from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52') order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> delete from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 07";
-- *************************************************************************
-- TESTUNIT : 08
-- DESCRIPTION : delete on parent with SQ on union view of children
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 08";
-- reset to original rows
delete from db2test.emp;
5 rows inserted/updated/deleted
ij> delete from db2test.emp2;
1 row inserted/updated/deleted
ij> delete from db2test.dept;
1 row inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete cascade;
0 rows inserted/updated/deleted
ij> commit;
ij> create view db2test.vempunion (vname, vmgrname, vdno) as
(select e.name, e.mgrname, e.dno
from db2test.emp e)
union all
(select e2.name, e2.mgrname, e2.dno from db2test.emp2 e2);
0 rows inserted/updated/deleted
ij> select * from db2test.dept where dno in (select vdno from
db2test.vempunion)
and dno in ('K55', 'K52') order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> delete from db2test.dept where dno in (select vdno from
db2test.vempunion)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 08";
-- "cleanup";
drop view VEMPJOIN;
0 rows inserted/updated/deleted
ij> drop view VEMPUNION;
0 rows inserted/updated/deleted
ij> drop table db2test.emp2;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> --drop view db2test.vempjoin;
--drop view db2test.vempunion;
commit;
ij> -- "cself304.sql ENDED";
-- #########################################################################
-- # TESTCASE NAME : cself311.sql
-- # LINE ITEM : Self-referencing subqueries
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases where of delete statements
-- # : where the deleted table also appears in a
-- # : subquery that qualifies which rows are changed
-- # : and the deleted table has a self-ref'g RI const.
-- # EXPECTED RESULTS : File should run successfully with no errors.
-- #########################################################################
-- "START OF TESTCASE: cself311.sql";
autocommit off;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp on delete
set null, dno char(3) references db2test.dept on delete
set null);
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.origemp on delete
set null, dno char(3) references db2test.origdept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- "END OF TESTUNIT: 01";
-- *************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on same table on RI set null col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.emp where name in (select name from db2test.emp
where mgrname = 'JOHN') order by 2,3,4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> delete from db2test.emp where name in (select name from db2test.emp
where mgrname = 'JOHN');
2 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |NULL |K55
13 |DAN |ROGER |K52
17 |DON |NULL |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |NULL |K55
ij> -- "END OF TESTUNIT: 02";
-- *************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : delete with 2 levels of SQ and self-ref in 2nd
-- : correlated to 1st SQ on foreign key
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.emp;
18 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp where dno in (select dno from db2test.dept D
where D.dno in (select dno from db2test.emp E where E.dno = D.dno
and e.mgrname = 'JOHN')) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in (select dno from db2test.dept D
where D.dno in (select dno from db2test.emp E where E.dno = D.dno
and e.mgrname = 'JOHN'));
10 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> -- "END OF TESTUNIT: 03";
-- *************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : delete with SQ GB Having SQ on
-- : modified table
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.emp;
10 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from db2test.emp
where mgrname = 'ASHOK')) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from db2test.emp
where mgrname = 'ASHOK'));
20 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> -- "END OF TESTUNIT: 04";
-- *************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : delete with SQ GB Having SQ on
-- : modified table -- 3 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from
db2test.dept D where dno in (select dno from db2test.emp E2
where D. dno = E2.dno))) order by 2, 3, 4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from
db2test.dept D where dno in (select dno from db2test.emp E2
where D. dno = E2.dno)));
20 rows inserted/updated/deleted
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> -- "END OF TESTUNIT: 05";
-- *************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : delete on view with SQ GB Having SQ on
-- : modified table -- 3 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.emp;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> create view db2test.vemp (vc0, vname, vmgrname, vdno) as
select * from db2test.emp where exists ( select max(mgrname) from
db2test.origemp group by dno having dno in (select dno from
db2test.dept D where dno in (select dno from db2test.emp E2
where D. dno = E2.dno)));
0 rows inserted/updated/deleted
ij> select * from db2test.vemp order by 2, 3, 4;
VC0 |VNAME |VMGRNAME |VDNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> delete from db2test.vemp;
ERROR 42Y24: View 'DB2TEST.VEMP' is not updatable. (Views are currently not updatable.)
ij> select * from db2test.emp order by name, mgrname, dno;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
10 |BOBBIE |HAMID |K55
13 |DAN |ROGER |K52
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
12 |JIM |ROGER |K52
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
3 |ROBIN |ASHOK |K51
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 06";
-- "cleanup";
drop view db2test.vemp;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> rollback;
ij> -- "cself311.clp ENDED";
-- #########################################################################
-- # TESTCASE NAME : cself312.sql
-- # LINE ITEM : Self-referencing subqueries
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases of delete statements
-- # : where the deleted table is connected to other
-- # : tables in the query by set null on delete.
-- # : shape of the RI tree is a 1 level star fanout.
-- #########################################################################
-- "START OF TESTCASE: cself312.sql";
autocommit off;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> create table db2test.secondemp (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp on delete set null,
dno char(3) references db2test.origdept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 01";
-- *************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on same table on RI set null col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.dept where dno in (select dno from db2test.emp
where mgrname = 'JOHN') order by 2,3;
C0 |DNO|DNAME
--------------------------
1 |K55|DB
ij> delete from db2test.dept where dno in (select dno from db2test.emp
where mgrname = 'JOHN');
1 row inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 02";
-- *************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : delete with 2 levels of SQ and self-ref in 2nd
-- : correlated to 1st SQ on foreign key
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
2 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept where dno in (select dno from
db2test.secondemp E
where E.dno in (select dno from db2test.emp D where E.dno = D.dno
and D.dno = 'K55')) order by 2, 3;
C0 |DNO|DNAME
--------------------------
1 |K55|DB
ij> delete from db2test.dept where dno in (select dno
from db2test.secondemp E
where E.dno in (select dno from db2test.emp D where E.dno = D.dno
and D.dno = 'K55'));
1 row inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 03";
-- *************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : delete with SQ GB Having SQ on
-- : child table
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
2 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept where exists ( select max(mgrname) from
db2test.secondemp group by dno having dno in (select dno from
db2test.emp where mgrname = 'ASHOK')) order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists ( select max(mgrname) from
db2test.secondemp group by dno having dno in (select dno from
db2test.emp where mgrname = 'ASHOK'));
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 04";
-- *************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : above -- 7 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept dtop where exists
(select * from db2test.secondemp where exists
(select dno from
db2test.dept D1 where dno = dtop.dno and dno in
(select dno from db2test.emp E2 where D1.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno and dno in
(select dno from db2test.emp E4 where E3.dno = E4.dno and dno in
(select dno from db2test.emp E5 where E4.dno = E5.dno and dno in
(select dno from db2test.emp E6 where E5.dno = E6.dno)
)))))) order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists
(select * from db2test.origemp where exists
(select dno from
db2test.dept D1 where dno = db2test.dept.dno and dno in
(select dno from db2test.emp E2 where D1.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno and dno in
(select dno from db2test.emp E4 where E3.dno = E4.dno and dno in
(select dno from db2test.emp E5 where E4.dno = E5.dno and dno in
(select dno from db2test.emp E6 where E5.dno = E6.dno)
))))));
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 05";
-- *************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : on second child table, delete set null on each
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> -- create a second child table like emp
create table db2test.emp2 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept dtop where exists
(select dno from db2test.emp2 E2 where Dtop.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno))
order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists
(select dno from db2test.emp2 E2 where db2test.dept.dno = E2.dno and dno in
(select dno from db2test.emp E3 where E2.dno = E3.dno));
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> -- "END OF TESTUNIT: 06";
-- *************************************************************************
-- TESTUNIT : 07
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : on second child table, delete set null on each
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 07";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept dtop where exists
(select dno from db2test.emp2 E2 where dtop.dno = E2.dno)
and exists
(select dno from db2test.emp E3 where dtop.dno = E3.dno)
order by 2,3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists
(select dno from db2test.emp2 E2 where db2test.dept.dno = E2.dno)
and exists
(select dno from db2test.emp E3 where db2test.dept.dno = E3.dno);
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> -- "END OF TESTUNIT: 07";
-- *************************************************************************
-- TESTUNIT : 08
-- DESCRIPTION : delete with SQ on child table correlated to SQ
-- : on second child table, delete set null on each
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 08";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.dept dtop where exists
(select dno from db2test.emp2 E2 where dtop.dno = E2.dno)
or exists
(select dno from db2test.emp E3 where dtop.dno = E3.dno)
order by 2, 3;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where exists
(select dno from db2test.emp2 E2 where db2test.dept.dno = E2.dno)
or exists
(select dno from db2test.emp E3 where db2test.dept.dno = E3.dno);
3 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |NULL
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
4 |JOE1 |ASHOK |NULL
5 |JOE2 |ASHOK |NULL
2 |JOHN |ASHOK |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
3 |ROBIN |ASHOK |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> -- "END OF TESTUNIT: 08";
-- *************************************************************************
-- TESTUNIT : 09
-- DESCRIPTION : delete on view with SQ GB Having SQ on
-- : modified table -- 3 levels
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 09";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> create view db2test.vempjoin (vname1, vname2, vmgrname, vdno) as
select e.name, e2.name, e.mgrname, e.dno
from db2test.emp e, db2test.emp2 e2
where e.dno = e2.dno;
0 rows inserted/updated/deleted
ij> select * from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52') order by 2, 3;
C0 |DNO|DNAME
--------------------------
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> -- "END OF TESTUNIT: 09";
-- *************************************************************************
-- TESTUNIT : 10
-- DESCRIPTION : delete on iudt where SQ on
-- : view with join on 15 child tables
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 10";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
1 row inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> -- create a third child table like emp
create table db2test.emp3 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 4th child table like emp
create table db2test.emp4 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 5th child table like emp
create table db2test.emp5 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 6th child table like emp
create table db2test.emp6 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 7th child table like emp
create table db2test.emp7 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp7 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 8th child table like emp
create table db2test.emp8 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp8 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 9th child table like emp
create table db2test.emp9 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp9 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 10th child table like emp
create table db2test.emp10 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp10 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 11th child table like emp
create table db2test.emp11 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp11 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 12th child table like emp
create table db2test.emp12 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp12 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 13th child table like emp
create table db2test.emp13 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp13 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 14th child table like emp
create table db2test.emp14 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp14 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 15th child table like emp
create table db2test.emp15 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp2 on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp15 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> create view db2test.vempjoin12 (vname1, vname2, vname3, vname4, vname5,
vname6, vname7, vname8, vname9, vname10, vname11, vname12,
vmgrname, vdno) as
select e.name, e2.name, e3.name, e4.name, e5.name, e6.name, e7.name,
e8.name, e9.name, e10.name, e11.name, e12.name,
e.mgrname, e.dno
from db2test.emp e, db2test.emp2 e2, db2test.emp3 e3, db2test.emp4 e4,
db2test.emp5 e5, db2test.emp6 e6, db2test.emp7 e7, db2test.emp8 e8,
db2test.emp9 e9, db2test.emp10 e10, db2test.emp11 e11,
db2test.emp12 e12
where e.dno = e2.dno
and e.dno = e2.dno
and e.dno = e2.dno
and e.dno = e3.dno
and e.dno = e4.dno
and e.dno = e5.dno
and e.dno = e6.dno
and e.dno = e7.dno
and e.dno = e8.dno
and e.dno = e9.dno
and e.dno = e10.dno
and e.dno = e11.dno
and e.dno = e12.dno;
0 rows inserted/updated/deleted
ij> commit;
ij> --CURRENTLY These queries hang in Cloudscape
--have to uncomment once they start passing
--select * from db2test.dept where dno in (select vdno from
-- db2test.vempjoin12)
-- and dno in ('K55', 'K52') order by 2, 3;
--delete from db2test.dept where dno in (select vdno from
-- db2test.vempjoin12)
-- and dno in ('K55', 'K52');
select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
2 |K52|OFC
1 |K55|DB
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp6 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp7 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp8 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp9 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp10 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp11 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp12 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp13 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp14 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp15 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 10";
-- *************************************************************************
-- TESTUNIT : 11
-- DESCRIPTION : delete with many SQ levels correl'd on child tables
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 11";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.emp3;
20 rows inserted/updated/deleted
ij> delete from db2test.emp4;
20 rows inserted/updated/deleted
ij> delete from db2test.emp5;
20 rows inserted/updated/deleted
ij> delete from db2test.emp6;
20 rows inserted/updated/deleted
ij> delete from db2test.emp7;
20 rows inserted/updated/deleted
ij> delete from db2test.emp8;
20 rows inserted/updated/deleted
ij> delete from db2test.emp9;
20 rows inserted/updated/deleted
ij> delete from db2test.emp10;
20 rows inserted/updated/deleted
ij> delete from db2test.emp11;
20 rows inserted/updated/deleted
ij> delete from db2test.emp12;
20 rows inserted/updated/deleted
ij> delete from db2test.emp13;
20 rows inserted/updated/deleted
ij> delete from db2test.emp14;
20 rows inserted/updated/deleted
ij> delete from db2test.emp15;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp7 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp8 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp9 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp10 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp11 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp12 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp13 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp14 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp15 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.dept d where
dno in (select dno from db2test.emp e where
e.dno = d.dno and e.dno in (select dno from db2test.emp2 e2 where
e2.dno = e.dno and e2.dno in (select dno from db2test.emp3 e3 where
e3.dno = e2.dno and e3.dno in (select dno from db2test.emp4 e4 where
e4.dno = e3.dno and e4.dno in (select dno from db2test.emp5 e5 where
e5.dno = e4.dno and e5.dno in (select dno from db2test.emp6 e6 where
e6.dno = e5.dno and e6.dno in ('K55', 'K52')))))))
order by 2, 3;
C0 |DNO|DNAME
--------------------------
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept d where
d.dno in (select e.dno from db2test.emp e where
e.dno = d.dno and e.dno in (select e2.dno from db2test.emp2 e2 where
e2.dno = e.dno and e2.dno in (select e3.dno from db2test.emp3 e3 where
e3.dno = e2.dno and e3.dno in (select e4.dno from db2test.emp4 e4 where
e4.dno = e3.dno and e4.dno in (select e5.dno from db2test.emp5 e5 where
e5.dno = e4.dno and e5.dno in (select e6.dno from db2test.emp6 e6 where
e6.dno = e5.dno and e6.dno in ('K55', 'K52')))))));
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp6 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp7 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp8 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp9 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp10 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp11 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp12 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp13 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp14 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp15 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> -- "END OF TESTUNIT: 11";
-- *************************************************************************
-- TESTUNIT : 12
-- DESCRIPTION : delete on view with union of 15 child tables
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 12";
-- reset to original rows
delete from db2test.dept;
1 row inserted/updated/deleted
ij> delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.secondemp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.emp3;
20 rows inserted/updated/deleted
ij> delete from db2test.emp4;
20 rows inserted/updated/deleted
ij> delete from db2test.emp5;
20 rows inserted/updated/deleted
ij> delete from db2test.emp6;
20 rows inserted/updated/deleted
ij> delete from db2test.emp7;
20 rows inserted/updated/deleted
ij> delete from db2test.emp8;
20 rows inserted/updated/deleted
ij> delete from db2test.emp9;
20 rows inserted/updated/deleted
ij> delete from db2test.emp10;
20 rows inserted/updated/deleted
ij> delete from db2test.emp11;
20 rows inserted/updated/deleted
ij> delete from db2test.emp12;
20 rows inserted/updated/deleted
ij> delete from db2test.emp13;
20 rows inserted/updated/deleted
ij> delete from db2test.emp14;
20 rows inserted/updated/deleted
ij> delete from db2test.emp15;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.secondemp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp7 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp8 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp9 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp10 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp11 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp12 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp13 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp14 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp15 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> commit;
ij> create view db2test.vempunion15 (vname,
vmgrname, vdno) as
(select e.name, e.mgrname, e.dno
from db2test.emp e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp2 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp3 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp4 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp5 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp6 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp7 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp8 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp9 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp10 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp11 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp12 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp13 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp14 e)
union all
(select e.name, e.mgrname, e.dno
from db2test.emp15 e);
0 rows inserted/updated/deleted
ij> select * from db2test.dept where dno in
(select vdno from db2test.vempunion15)
and dno in ('K55', 'K52') order by 2, 3;
C0 |DNO|DNAME
--------------------------
2 |K52|OFC
1 |K55|DB
ij> delete from db2test.dept where dno in
(select vdno from db2test.vempunion15)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME
--------------------------
3 |K51|CS
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.secondemp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp6 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp7 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp8 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp9 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp10 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp11 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp12 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp13 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp14 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp15 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> -- "END OF TESTUNIT: 12";
-- "cleanup";
drop view db2test.vempunion15;
0 rows inserted/updated/deleted
ij> drop view db2test.vempjoin12;
0 rows inserted/updated/deleted
ij> drop view db2test.vempjoin;
0 rows inserted/updated/deleted
ij> drop table db2test.emp15;
0 rows inserted/updated/deleted
ij> drop table db2test.emp14;
0 rows inserted/updated/deleted
ij> drop table db2test.emp13;
0 rows inserted/updated/deleted
ij> drop table db2test.emp12;
0 rows inserted/updated/deleted
ij> drop table db2test.emp11;
0 rows inserted/updated/deleted
ij> drop table db2test.emp10;
0 rows inserted/updated/deleted
ij> drop table db2test.emp9;
0 rows inserted/updated/deleted
ij> drop table db2test.emp8;
0 rows inserted/updated/deleted
ij> drop table db2test.emp7;
0 rows inserted/updated/deleted
ij> drop table db2test.emp6;
0 rows inserted/updated/deleted
ij> drop table db2test.emp5;
0 rows inserted/updated/deleted
ij> drop table db2test.emp4;
0 rows inserted/updated/deleted
ij> drop table db2test.emp3;
0 rows inserted/updated/deleted
ij> drop table db2test.emp2;
0 rows inserted/updated/deleted
ij> drop table db2test.secondemp;
0 rows inserted/updated/deleted
ij> drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> --drop view db2test.vempjoin;
--drop view db2test.vempjoin12;
--drop view db2test.vempunion15;
-- *************************************************************************
-- NO MORE TESTUNITS. SUMMARIZE TESTCASE RESULTS AND HOUSE KEEPING
-- *************************************************************************
commit;
ij> -- #########################################################################
-- # TESTCASE NAME : cself313.sql
-- # LINE ITEM : Self-referencing subqueries
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases where of delete statements
-- # : where the deleted table is connected to other
-- # : tables in the query by set null on delete.
-- # : shape of the RI tree is a 6way star.
-- #########################################################################
-- "START OF TESTCASE: cself313.sql";
autocommit off;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a second child table like emp
create table db2test.emp2 (c0 int, name char(10) not null primary key,
mgrname char(10)
references db2test.emp on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a third child table like emp
create table db2test.emp3 (c0 int, name char(10) not null primary key,
mgrname char(10)
references db2test.emp on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 4th child table like emp
create table db2test.emp4 (c0 int, name char(10) not null primary key,
mgrname char(10)
references db2test.emp on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 5th child table like emp
create table db2test.emp5 (c0 int, name char(10) not null primary key,
mgrname char(10)
references db2test.emp on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a 6th child table like emp
create table db2test.emp6 (c0 int, name char(10) not null primary key,
mgrname char(10)
references db2test.emp on delete set null,
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp6 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- "END OF TESTUNIT: 01";
-- *************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on child table on RI set null col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.emp e where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN' and e3.name = e2.mgrname));
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN' and e3.name = e2.mgrname));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 02";
-- *************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : delete where SQ on child table on RI set null col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.emp3;
20 rows inserted/updated/deleted
ij> delete from db2test.emp4;
20 rows inserted/updated/deleted
ij> delete from db2test.emp5;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN')) order by 2,3,4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in (select dno from db2test.emp3 e3
where e3.dno in (select dno from db2test.emp2 e2
where mgrname = 'JOHN'));
10 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> -- "END OF TESTUNIT: 03";
-- *************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp;
10 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.emp3;
20 rows inserted/updated/deleted
ij> delete from db2test.emp4;
20 rows inserted/updated/deleted
ij> delete from db2test.emp5;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e5.name = e4.mgrname and e4.dno in
(select dno from db2test.emp3 e3 where e4.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e3.name = e2.mgrname and
e2.dno in (select dno from db2test.emp e1
where e1.name = e.mgrname and e1.mgrname = 'JOHN')))))
order by 1,2,3;
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e5.name = e4.mgrname and e4.dno in
(select dno from db2test.emp3 e3 where e4.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e3.name = e2.mgrname and
e2.dno in (select dno from db2test.emp e1
where e1.name = db2test.emp.mgrname and
e1.mgrname = 'JOHN')))));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 04";
-- *************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp;
20 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.emp3;
20 rows inserted/updated/deleted
ij> delete from db2test.emp4;
20 rows inserted/updated/deleted
ij> delete from db2test.emp5;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e5.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e4.dno = e3.dno and
e3.dno in (select dno from db2test.emp2 e2
where e3.name = e2.mgrname group by dno having
e2.dno in (select dno from db2test.emp e1
where e1.name = e.mgrname and e1.mgrname = 'JOHN')))))
order by 2,3,4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp e
where e.dno in (select e5.dno from db2test.emp5 e5
where e5.dno in (select e4.dno from db2test.emp4 e4 where
e5.name = e4.mgrname group by e4.dno having dno in
(select e3.dno from db2test.emp3 e3 where e4.dno = e3.dno and
e3.dno in (select e2.dno from db2test.emp2 e2
where e3.name = e2.mgrname group by e2.dno having
e2.dno in (select e1.dno from db2test.emp e1
where e1.name = e.mgrname and e1.mgrname = 'JOHN')))));
8 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> -- "END OF TESTUNIT: 05";
-- *************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having, correl to iudt
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp;
12 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.emp3;
20 rows inserted/updated/deleted
ij> delete from db2test.emp4;
20 rows inserted/updated/deleted
ij> delete from db2test.emp5;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e.name = e2.mgrname group by dno having
e2.dno in (select dno from db2test.emp e1
where e.mgrname = 'JOHN'))))) order by 2,3,4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> delete from db2test.emp e
where e.dno in (select e5.dno from db2test.emp5 e5
where e5.dno in (select e4.dno from db2test.emp4 e4 where
e.name = e4.mgrname group by e4.dno having e4.dno in
(select e3.dno from db2test.emp3 e3 where e.name = e3.mgrname and
e3.dno in (select e2.dno from db2test.emp2 e2
where e.name = e2.mgrname group by e2.dno having
e2.dno in (select e1.dno from db2test.emp e1
where e.mgrname = 'JOHN')))));
2 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> -- "END OF TESTUNIT: 06";
-- *************************************************************************
-- TESTUNIT : 07
-- DESCRIPTION : delete where SQ chain reversing RI child chain
-- : combining where and having, correl to grandparent
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 07";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp;
18 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.emp3;
20 rows inserted/updated/deleted
ij> delete from db2test.emp4;
20 rows inserted/updated/deleted
ij> delete from db2test.emp5;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp3 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp4 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp5 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> select * from db2test.emp e
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
e.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.dno = e2.dno group by dno having
e2.dno in (select dno from db2test.emp e1
where e.mgrname = 'JOHN'))))) order by 2,3,4;
C0 |NAME |MGRNAME |DNO
--------------------------------------
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
ij> delete from db2test.emp
where dno in (select dno from db2test.emp5 e5
where e5.dno in (select dno from db2test.emp4 e4 where
db2test.emp.name = e4.mgrname group by dno having dno in
(select dno from db2test.emp3 e3 where e5.name = e3.mgrname and
e3.dno in (select dno from db2test.emp2 e2
where e4.dno = e2.dno group by dno having
e2.dno in (select dno from db2test.emp e1
where db2test.emp.mgrname = 'JOHN')))));
2 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp3 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp4 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> select * from db2test.emp5 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> -- "END OF TESTUNIT: 07";
-- "cleanup";
drop table db2test.emp6;
0 rows inserted/updated/deleted
ij> drop table db2test.emp5;
0 rows inserted/updated/deleted
ij> drop table db2test.emp4;
0 rows inserted/updated/deleted
ij> drop table db2test.emp3;
0 rows inserted/updated/deleted
ij> drop table db2test.emp2;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> rollback;
ij> -- "cself313.clp ENDED";
-- #########################################################################
-- # TESTCASE NAME : cself314.sql
-- # LINE ITEM : Self-referencing subqueries
-- # COMPONENT(S) : SQN and SQR
-- # DESCRIPTION : Allow use of subqueries on the same table being
-- # : inserted, deleted, or updated. Cursors updated
-- # : or delete where current of are now similarly
-- # : unrestricted. Also allowed are subqueries
-- # : on tables related to the modified table by
-- # : referential relationships, either directly or
-- # : indirectly.
-- # : This file covers cases where of delete statements
-- # : where the deleted table is connected to other
-- # : tables in the query by set null on delete.
-- # : shape of the RI tree is a 3-way cycle to parent
-- "START OF TESTCASE: cself314.sql";
autocommit off;
ij> -- *************************************************************************
-- TESTUNIT : 01
-- DESCRIPTION : Create tables db2test.emp
-- : insert some data into it
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 01";
create table db2test.dept (c0 int, dno char(3) not null primary key,
dname char(10), dmgrname char(10));
0 rows inserted/updated/deleted
ij> create table db2test.origdept (c0 int, dno char(3) not null primary key,
dname char(10), dmgrname char(10));
0 rows inserted/updated/deleted
ij> insert into db2test.dept values (1, 'K55', 'DB', 'JOHN');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (2, 'K52', 'OFC', 'ROBIN');
1 row inserted/updated/deleted
ij> insert into db2test.dept values (3, 'K51', 'CS', 'ASHOK');
1 row inserted/updated/deleted
ij> insert into db2test.origdept select * from db2test.dept;
3 rows inserted/updated/deleted
ij> create table db2test.emp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3) references db2test.dept
on delete set null );
0 rows inserted/updated/deleted
ij> insert into db2test.emp (c0, name, dno) values (1, 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (2, 'JOHN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (3, 'ROBIN', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (4, 'JOE1', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (5, 'JOE2', 'ASHOK', 'K51');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (6, 'HAMID', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (7, 'TRUONG', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (8, 'LARRY1', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (9, 'LARRY2', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (10, 'BOBBIE', 'HAMID', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (11, 'ROGER', 'ROBIN', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (12, 'JIM', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (13, 'DAN', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (14, 'SAM1', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (15, 'SAM2', 'ROGER', 'K52');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (16, 'GUY', 'JOHN', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (17, 'DON', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (18, 'MONICA', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (19, 'LILY1', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> insert into db2test.emp values (20, 'LILY2', 'GUY', 'K55');
1 row inserted/updated/deleted
ij> create table db2test.origemp (c0 int, name char(10) not null primary key,
mgrname char(10),
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.origemp select * from db2test.emp;
20 rows inserted/updated/deleted
ij> -- create a second child table like emp
create table db2test.emp2 (c0 int, name char(10) not null primary key,
mgrname char(10) references db2test.emp on delete set null,
dno char(3));
0 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.emp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete set null;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 01";
-- ************************************************************************
-- TESTUNIT : 02
-- DESCRIPTION : delete where SQ on child table on RI set null col
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 02";
select * from db2test.emp e where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where dmgrname = 'JOHN'))
order by name;
C0 |NAME |MGRNAME |DNO
--------------------------------------
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> delete from db2test.emp where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where dmgrname = 'JOHN'));
10 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |NULL |K55
17 |DON |NULL |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |NULL |K55
9 |LARRY2 |NULL |K55
19 |LILY1 |NULL |K55
20 |LILY2 |NULL |K55
18 |MONICA |NULL |K55
7 |TRUONG |NULL |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 02";
-- ************************************************************************
-- TESTUNIT : 03
-- DESCRIPTION : same as 02, but with correlation to top table
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 03";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
10 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete set null;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where mgrname = 'john' and e2.name = d.dmgrname));
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp where dno in (select dno from db2test.emp2 e2
where e2.dno in (select dno from db2test.dept d
where mgrname = 'john' and e2.name = d.dmgrname));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 03";
-- ************************************************************************
-- TESTUNIT : 04
-- DESCRIPTION : same as 02 but SQ's reversed
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 04";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete set null;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in
(select dno from db2test.dept d
where d.dno in
(select dno from db2test.emp2 e2
where e2.mgrname = 'john'));
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp where dno in
(select dno from db2test.dept d
where d.dno in
(select dno from db2test.emp2 e2
where e2.mgrname = 'john'));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 04";
-- ************************************************************************
-- TESTUNIT : 05
-- DESCRIPTION : same as 03 but SQ's reversed
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 05";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete set null;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in
(select dno from db2test.dept d
where d.dno = e.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'john'));
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp where dno in
(select dno from db2test.dept d
where d.dno = db2test.emp.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'john'));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 05";
-- ************************************************************************
-- TESTUNIT : 06
-- DESCRIPTION : same as 05 but extra table
-- EXPECTED RESULTS : SQL commands should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 06";
-- reset to original rows
delete from db2test.dept;
3 rows inserted/updated/deleted
ij> delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete set null;
0 rows inserted/updated/deleted
ij> commit;
ij> select * from db2test.emp e where dno in
(select dno from db2test.origdept where dno in
(select dno from db2test.dept d
where d.dno = e.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'john')));
C0 |NAME |MGRNAME |DNO
--------------------------------------
ij> delete from db2test.emp where dno in
(select dno from db2test.origdept where dno in
(select dno from db2test.dept d
where d.dno = db2test.emp.dno and d.dno in
(select dno from db2test.emp2 e2 where e2.dno = d.dno and
e2.mgrname = 'john')));
0 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> select * from db2test.dept order by dno, dname, dmgrname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 06";
-- *************************************************************************
-- TESTUNIT : 07
-- DESCRIPTION : delete on parent with SQ on join view of children
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 07";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
3 rows inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete set null;
0 rows inserted/updated/deleted
ij> commit;
ij> create view db2test.vempjoin (vname1, vname2, vmgrname, vdno) as
select e.name, e2.name, e.mgrname, e.dno
from db2test.emp e, db2test.emp2 e2
where e.dno = e2.dno;
0 rows inserted/updated/deleted
ij> select * from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52')
order by dno;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> delete from db2test.dept where dno in (select vdno from
db2test.vempjoin)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 07";
-- *************************************************************************
-- TESTUNIT : 08
-- DESCRIPTION : delete on parent with SQ on union view of children
-- EXPECTED RESULTS : SQL command should complete successfully
-- *************************************************************************
-- "START OF TESTUNIT: 08";
-- reset to original rows
delete from db2test.emp;
20 rows inserted/updated/deleted
ij> delete from db2test.emp2;
20 rows inserted/updated/deleted
ij> delete from db2test.dept;
1 row inserted/updated/deleted
WARNING 02000: No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
ij> insert into db2test.dept select * from db2test.origdept;
3 rows inserted/updated/deleted
ij> insert into db2test.emp select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> insert into db2test.emp2 select * from db2test.origemp;
20 rows inserted/updated/deleted
ij> alter table db2test.dept add constraint dmgr foreign key (dmgrname)
references db2test.emp2 on delete set null;
0 rows inserted/updated/deleted
ij> commit;
ij> create view db2test.vempunion (vname, vmgrname, vdno) as
(select e.name, e.mgrname, e.dno
from db2test.emp e)
union all
(select e2.name, e2.mgrname, e2.dno from db2test.emp2 e2);
0 rows inserted/updated/deleted
ij> -- #BEGIN;
select * from db2test.dept where dno in (select vdno from
db2test.vempunion)
and dno in ('K55', 'K52')
order by dno;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
2 |K52|OFC |ROBIN
1 |K55|DB |JOHN
ij> -- #END;
delete from db2test.dept where dno in (select vdno from
db2test.vempunion)
and dno in ('K55', 'K52');
2 rows inserted/updated/deleted
ij> select * from db2test.dept order by dno, dname;
C0 |DNO|DNAME |DMGRNAME
-------------------------------------
3 |K51|CS |ASHOK
ij> select * from db2test.emp order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
10 |BOBBIE |HAMID |NULL
13 |DAN |ROGER |NULL
17 |DON |GUY |NULL
16 |GUY |JOHN |NULL
6 |HAMID |JOHN |NULL
12 |JIM |ROGER |NULL
8 |LARRY1 |HAMID |NULL
9 |LARRY2 |HAMID |NULL
19 |LILY1 |GUY |NULL
20 |LILY2 |GUY |NULL
18 |MONICA |GUY |NULL
11 |ROGER |ROBIN |NULL
14 |SAM1 |ROGER |NULL
15 |SAM2 |ROGER |NULL
7 |TRUONG |HAMID |NULL
ij> select * from db2test.emp2 order by dno, name, mgrname;
C0 |NAME |MGRNAME |DNO
--------------------------------------
1 |ASHOK |NULL |K51
4 |JOE1 |ASHOK |K51
5 |JOE2 |ASHOK |K51
2 |JOHN |ASHOK |K51
3 |ROBIN |ASHOK |K51
13 |DAN |ROGER |K52
12 |JIM |ROGER |K52
11 |ROGER |ROBIN |K52
14 |SAM1 |ROGER |K52
15 |SAM2 |ROGER |K52
10 |BOBBIE |HAMID |K55
17 |DON |GUY |K55
16 |GUY |JOHN |K55
6 |HAMID |JOHN |K55
8 |LARRY1 |HAMID |K55
9 |LARRY2 |HAMID |K55
19 |LILY1 |GUY |K55
20 |LILY2 |GUY |K55
18 |MONICA |GUY |K55
7 |TRUONG |HAMID |K55
ij> alter table db2test.dept drop constraint dmgr;
0 rows inserted/updated/deleted
ij> commit;
ij> -- "END OF TESTUNIT: 08";
-- "cleanup";
drop view db2test.vempjoin ;
0 rows inserted/updated/deleted
ij> drop view db2test.vempunion;
0 rows inserted/updated/deleted
ij> drop table db2test.emp2;
0 rows inserted/updated/deleted
ij> drop table db2test.emp;
0 rows inserted/updated/deleted
ij> drop table db2test.origemp;
0 rows inserted/updated/deleted
ij> drop table db2test.dept;
0 rows inserted/updated/deleted
ij> drop table db2test.origdept;
0 rows inserted/updated/deleted
ij> -- "cself314.clp ENDED";
drop schema db2test restrict;
0 rows inserted/updated/deleted
ij> -- END OF REFACTIONS1.sql --
;
ij>