Select from Insert
September 22, 2011
People imagination has no limits. Where does it lead SQL? Here is some bizarre syntax:
SELECT column1 FROM FINAL TABLE (INSERT INTO t1 VALUES(1,'John Smith') )
Wow, a whole semicolon has been spared — at the expense of syntax confusing relation with operator!
You would think DB2 designers would become laughing stock of SQL community? Wrong. Be prepared for some competition:
WITH sal1 AS
(
SELECT * FROM NEW
(
INSERT INTO EMPLOYEES(EMPLOYEE_ID, SALARY) VALUES(207, 1000)
)
)
, sal2 AS
(
SELECT * FROM NEW
(
UPDATE EMPLOYEES SET SALARY = SALARY*1.1
)
)
SELECT * FROM EMPLOYEES;
Then, why not INSERT as SELECT FROM (INSERT as SELECT), and so on.