Michael wrote:
I am trying to INSERT only the first row returned from a subselect, is
this possible? I'm on DB2 v8 on z/OS.
Non-working Example:
INSERT into some_table (
SELECT id
FROM some_other_table
WHERE conditions are met
FETCH FIRST 1 ROWS ONLY
)
Thanks.
I'm on Solaris, so this may be of no help.
This "worked for me":
DECLARE GLOBAL TEMPORARY TABLE some_table(a int)
DECLARE GLOBAL TEMPORARY TABLE some_other_table(id int)
INSERT INTO SESSION.some_other_table VALUES (1), (2)
INSERT INTO SESSION.some_table (SELECT id FROM SESSION.some_other_table
FETCH FIRST 1 ROWS ONLY)
SELECT * FROM SESSION.some_table
DROP TABLE SESSION.some_other_table
DROP TABLE SESSION.some_table
COMMIT
What was the error that you received?
B.