cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
create t set a, b, c;
insert into t values (1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4);
select from t;
create view g (a, sumb) as select a, sum (b) from t group by a sort by a;
select from g;
select sum (a) from g;
create view s (suma, sumb, sumc) as select sum (a), sum (b), sum (c) from t;
select suma + 1 from s;
select from s where suma = 1;
select from s having suma = 1;
select from s, tt;
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* create t set a, b, c;
* insert into t values (1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4);
* select from t;
     a       b       c

     1       1       1
     1       2       2
     2       3       3
     3       4       4
* create view g (a, sumb) as select a, sum (b) from t group by a sort by a;
* select from g;
     a         sumb

     1            3
     2            3
     3            4
* select sum (a) from g;
     SUM(a)

          6
* create view s (suma, sumb, sumc) as select sum (a), sum (b), sum (c) from t;
* select suma + 1 from s;
 (suma + 1)

          8
* select from s where suma = 1;
       suma         sumb         sumc

* select from s having suma = 1;

*** Error: attribute 'suma' not allowed in having clause
* select from s, tt;
       suma         sumb         sumc      aa

          7           10           10       1
          7           10           10       3
          7           10           10       5
* 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Test for invalid operation on aggregate view.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
cat > stdout.jp_euc <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* create t set a, b, c;
* insert into t values (1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4);
* select from t;
     a       b       c

     1       1       1
     1       2       2
     2       3       3
     3       4       4
* create view g (a, sumb) as select a, sum (b) from t group by a sort by a;
* select from g;
     a         sumb

     1            3
     2            3
     3            4
* select sum (a) from g;
     SUM(a)

          6
* create view s (suma, sumb, sumc) as select sum (a), sum (b), sum (c) from t;
* select suma + 1 from s;
 (suma + 1)

          8
* select from s where suma = 1;
       suma         sumb         sumc

* select from s having suma = 1;

*** Error: HAVING ʸǥȥӥ塼 'suma' λϤǤޤ
* select from s, tt;
       suma         sumb         sumc      aa

          7           10           10       1
          7           10           10       3
          7           10           10       5
* 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout.jp_euc
