1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| SQL> CREATE TABLE aa_toto (c1 number PRIMARY KEY, c2 varchar2(30));
Table created.
SQL>
SQL> INSERT INTO aa_toto VALUES (1,'aaaaaaa');
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL> insert into aa_toto a
2 select mx, str
3 from (select NVL(MAX(c1),0)+1 mx, 'aaaaaaa' str FROM aa_toto) b
4 where str not in (select c2 from aa_toto);
0 rows created.
SQL> insert into aa_toto a
2 select mx, str
3 from (select NVL(MAX(c1),0)+1 mx, 'bbbbbbb' str FROM aa_toto) b
4 where str not in (select c2 from aa_toto);
1 row created.
SQL> insert into aa_toto a
2 select mx, str
3 from (select NVL(MAX(c1),0)+1 mx, 'bbbbbbb' str FROM aa_toto) b
4 where str not in (select c2 from aa_toto);
0 rows created.
SQL> |