RR wrote:
Hi,
It appears that DB2 has an arbitrary restriction on the use of "fetch first
N rows".
When asking question about any software product, it is expected that platform,
OS and product version are provided.
I want to insert into a table from a large table query, but only insert the
first N rows:
insert into target (select colA,colB from source where conditions fetch
first 1000 rows only);
DB2 compains about this.
When asking question about any siftware product it is also expected that any
error or warning messages are quoted.
Does anyone have a workaround for this?
Yes - I used DB2 UDB V8.2 as identified by:
D:\Working>db2level
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL08020" with
level identifier "03010106".
Informational tokens are "DB2 v8.1.7.445", "s040812", "WR21342", and FixPak "7".
Product is installed at "D:\SQLLIB".
I used SAMPLE database - table ORG. First I created a copy of ORG:
D:\Working>db2 create table org2 like org
DB20000I The SQL command completed successfully.
Then I inserted first 3 rows from ORG ordered by location:
D:\Working>db2 insert into org2 (select * from org order by location fetch first
3 rows only)
DB20000I The SQL command completed successfully.
Finally I displayed contents of ORG2:
D:\Working>db2 select * from org2
DEPTNUMB DEPTNAME MANAGER DIVISION LOCATION
-------- -------------- ------- ---------- -------------
38 South Atlantic 30 Eastern Atlanta
15 New England 50 Eastern Boston
42 Great Lakes 100 Midwest Chicago
I don't see any problems - do you?
Jan M. Nelken