cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
: "export multi level view and referential constraints "

empcmd $MSTESTDB "create ta( a1, a2 );"
empcmd $MSTESTDB "create tb( b1, b2 );"

empcmd $MSTESTDB "create view a3view as select a2, b2 from ta, tb where a1=b1;"
empcmd $MSTESTDB "create view a2view as select from a3view;"
empcmd $MSTESTDB "create view a1view as select from a2view;"

empcmd $MSTESTDB "create refer 'ref1' a1view set a2 insert ta set a1;"
empcmd $MSTESTDB "create refer 'ref2' a1view(a2) insert tb set b2;"
empcmd $MSTESTDB "create refer 'ref3' a2view set  a2, b2 insert ta set a1, a2;"
empcmd $MSTESTDB "create refer 'ref4' a2view( a2, b2)  insert tb( b1, b2);"
empcmd $MSTESTDB "create refer 'ref5' a3view( a2, b2)  insert ta( a1, a2);"
empcmd $MSTESTDB "create refer 'ref6' a3view( a2, b2)  insert tb( b1, b2);"

empcmd $MSTESTDB "create refer 'ref7' ta( a1, a2 ) insert tb ( b1, b2 );"
empcmd $MSTESTDB "create refer 'self' ta( a1, a2 ) insert ta ( a1, a2 );"

empexpt -TESTMODE -v testout1 $MSTESTDB "a1view" "a2view" "a3view" "ta" "tb"
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 755 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'

**  Table: ta  **
    exporting the table definition...
    exporting data...
    exporting referential constraints...
    exporting lock levels...

**  Table: tb  **
    exporting the table definition...
    exporting data...
    exporting lock levels...

**  View: a3view  **
    exporting the view definition...
    exporting referential constraints...

**  View: a2view  **
    exporting the view definition...
    exporting referential constraints...

**  View: a1view  **
    exporting the view definition...
    exporting referential constraints...

*** export complete ***
<!HEADER!>

x
<262>
c
<1>

 <!ENDHEADER!>
<!MODHEAD!>
 <!ENDMODHEAD!>
<!TABHEAD!>
a1view
VIEW3
a2view
VIEW2
a3view
VIEW1
ta
0
tb
0
 <!ENDTABHEAD!>
<!TABLE!>
ta
<!CREATE!>
create table 'ta' (attr 'a1' integer,attr 'a2' integer)
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'ta' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'ta' to user as 'CREATOR' with grant option;
<!DATA!>
0
2
a1
a2

<!REFER!>
 'ref7' 2 'a1' 'a2' insert '' 'tb' 'b1' 'b2'
 'self' 2 'a1' 'a2' insert '' 'ta' 'a1' 'a2'
<!LOCK!>
lock level on table 'ta' is record
<!TABLE!>
tb
<!CREATE!>
create table 'tb' (attr 'b1' integer,attr 'b2' integer)
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'tb' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'tb' to user as 'CREATOR' with grant option;
<!DATA!>
0
2
b1
b2

<!LOCK!>
lock level on table 'tb' is record
<!TABLE!>
a3view
<!VIEW!>
create view 'a3view' ( 'a2', 'b2') as select attr 'a2', attr 'b2' from 'ta', 'tb' where (attr 'a1' = attr 'b1')
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'a3view' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'a3view' to user as 'CREATOR' with grant option;
<!REFER!>
 'ref5' 2 'a2' 'b2' insert '' 'ta' 'a1' 'a2'
 'ref6' 2 'a2' 'b2' insert '' 'tb' 'b1' 'b2'
<!TABLE!>
a2view
<!VIEW!>
create view 'a2view' ( 'a2', 'b2') as select *  from 'a3view'
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'a2view' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'a2view' to user as 'CREATOR' with grant option;
<!REFER!>
 'ref3' 2 'a2' 'b2' insert '' 'ta' 'a1' 'a2'
 'ref4' 2 'a2' 'b2' insert '' 'tb' 'b1' 'b2'
<!TABLE!>
a1view
<!VIEW!>
create view 'a1view' ( 'a2', 'b2') as select *  from 'a2view'
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'a1view' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'a1view' to user as 'CREATOR' with grant option;
<!REFER!>
 'ref1' 1 'a2' insert '' 'ta' 'a1'
 'ref2' 1 'a2' insert '' 'tb' 'b2'
 <!ENDFILE!>
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > stdout.jp_euc <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'

**  Table: ta  **
    ơ֥ݡ档...
    ǡݡ档...
    ե󥷥륳󥹥ȥ쥤ȥݡ档...
    å٥륨ݡ档...

**  Table: tb  **
    ơ֥ݡ档...
    ǡݡ档...
    å٥륨ݡ档...

**  View: a3view  **
    ӥ塼ݡ档...
    ե󥷥륳󥹥ȥ쥤ȥݡ档...

**  View: a2view  **
    ӥ塼ݡ档...
    ե󥷥륳󥹥ȥ쥤ȥݡ档...

**  View: a1view  **
    ӥ塼ݡ档...
    ե󥷥륳󥹥ȥ쥤ȥݡ档...

*** ݡȽλ ***
<!HEADER!>

x
<262>
c
<1>

 <!ENDHEADER!>
<!MODHEAD!>
 <!ENDMODHEAD!>
<!TABHEAD!>
a1view
VIEW3
a2view
VIEW2
a3view
VIEW1
ta
0
tb
0
 <!ENDTABHEAD!>
<!TABLE!>
ta
<!CREATE!>
create table 'ta' (attr 'a1' integer,attr 'a2' integer)
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'ta' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'ta' to user as 'CREATOR' with grant option;
<!DATA!>
0
2
a1
a2

<!REFER!>
 'ref7' 2 'a1' 'a2' insert '' 'tb' 'b1' 'b2'
 'self' 2 'a1' 'a2' insert '' 'ta' 'a1' 'a2'
<!LOCK!>
lock level on table 'ta' is record
<!TABLE!>
tb
<!CREATE!>
create table 'tb' (attr 'b1' integer,attr 'b2' integer)
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'tb' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'tb' to user as 'CREATOR' with grant option;
<!DATA!>
0
2
b1
b2

<!LOCK!>
lock level on table 'tb' is record
<!TABLE!>
a3view
<!VIEW!>
create view 'a3view' ( 'a2', 'b2') as select attr 'a2', attr 'b2' from 'ta', 'tb' where (attr 'a1' = attr 'b1')
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'a3view' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'a3view' to user as 'CREATOR' with grant option;
<!REFER!>
 'ref5' 2 'a2' 'b2' insert '' 'ta' 'a1' 'a2'
 'ref6' 2 'a2' 'b2' insert '' 'tb' 'b1' 'b2'
<!TABLE!>
a2view
<!VIEW!>
create view 'a2view' ( 'a2', 'b2') as select *  from 'a3view'
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'a2view' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'a2view' to user as 'CREATOR' with grant option;
<!REFER!>
 'ref3' 2 'a2' 'b2' insert '' 'ta' 'a1' 'a2'
 'ref4' 2 'a2' 'b2' insert '' 'tb' 'b1' 'b2'
<!TABLE!>
a1view
<!VIEW!>
create view 'a1view' ( 'a2', 'b2') as select *  from 'a2view'
<!PRIVILEGE!>
grant alter,drop,empty,index,sort on 'a1view' to 'CREATOR' as 'CREATOR';
<!PRIVILEGE!>
grant delete,insert,select,update,display on 'a1view' to user as 'CREATOR' with grant option;
<!REFER!>
 'ref1' 1 'a2' insert '' 'ta' 'a1'
 'ref2' 1 'a2' insert '' 'tb' 'b2'
 <!ENDFILE!>
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout.jp_euc
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Test export utility, multi level views and referential constraints.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
