473,586 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to insert X rows into a table from a Select clause?

1 New Member
I'm trying to Insert 300.000 rows (or thereabouts) into a table (via QMF) using the following Select clause:

#
Insert into table_name
( Select row1, row2, row..x
from table_name2
Fetch first 300000 rows only);
#

The only message I get is that there's an error with the Fecth statement.

A friend told that this is happening due to the operating mode of the DB (Compatibility Mode and New function mode).

Is this true?
Is there anyway of getting a fixed number of rows into a table without usig the Fetch clause ?

Thanx in advance for any kind of help you can give me.

Loix
Aug 21 '09 #1
1 3686
vijay2082
112 New Member
Hi Loix,

works great for me...

C:\Users\vijay> db2level
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL09017" with
level identifier "02080107".
Informational tokens are "DB2 v9.1.700.855", "s090308", "WR21434", and Fix Pack
"7".
Product is installed at "C:\PROGRA~1\IB M\SQLLIB" with DB2 Copy Name "DB2COPY1".


C:\Users\vijay> db2 connect to paulb001

Database Connection Information

Database server = DB2/NT 9.1.7
SQL authorization ID = VIJAY
Local database alias = PAULB001


C:\Users\vijay> db2 list tables for schema db2admin

Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------

0 record(s) selected.


C:\Users\vijay> db2 list tables for schema syscat

Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
ATTRIBUTES SYSCAT V 2009-07-17-22.09.11.254002
BUFFERPOOLDBPAR TITIONS SYSCAT V 2009-07-17-22.09.11.257001
BUFFERPOOLNODES SYSCAT V 2009-07-17-22.09.11.259002
BUFFERPOOLS SYSCAT V 2009-07-17-22.09.11.260003
CASTFUNCTIONS SYSCAT V 2009-07-17-22.09.11.262000
CHECKS SYSCAT V 2009-07-17-22.09.11.263001
COLAUTH SYSCAT V 2009-07-17-22.09.11.264003
COLCHECKS SYSCAT V 2009-07-17-22.09.11.265003
COLDIST SYSCAT V 2009-07-17-22.09.11.267001
COLGROUPCOLS SYSCAT V 2009-07-17-22.09.11.269003
COLGROUPDIST SYSCAT V 2009-07-17-22.09.11.270003
COLGROUPDISTCOU NTS SYSCAT V 2009-07-17-22.09.11.272003
COLGROUPS SYSCAT V 2009-07-17-22.09.11.268002
COLIDENTATTRIBU TES SYSCAT V 2009-07-17-22.09.11.329001
COLOPTIONS SYSCAT V 2009-07-17-22.09.11.276003
COLUMNS SYSCAT V 2009-07-17-22.09.11.280000
COLUSE SYSCAT V 2009-07-17-22.09.11.332000
CONSTDEP SYSCAT V 2009-07-17-22.09.11.333001
DATAPARTITIONEX PRESSION SYSCAT V 2009-07-17-22.09.11.336000
DATAPARTITIONS SYSCAT V 2009-07-17-22.09.11.337001
DATATYPES SYSCAT V 2009-07-17-22.09.11.340002
DBAUTH SYSCAT V 2009-07-17-22.09.11.342003
DBPARTITIONGROU PDEF SYSCAT V 2009-07-17-22.09.11.446001
DBPARTITIONGROU PS SYSCAT V 2009-07-17-22.09.11.447003
EVENTMONITORS SYSCAT V 2009-07-17-22.09.11.448003
EVENTS SYSCAT V 2009-07-17-22.09.11.450001
EVENTTABLES SYSCAT V 2009-07-17-22.09.11.483001
FULLHIERARCHIES SYSCAT V 2009-07-17-22.09.11.484003
FUNCDEP SYSCAT V 2009-07-17-22.09.11.486000
FUNCMAPOPTIONS SYSCAT V 2009-07-17-22.09.11.486004
FUNCMAPPARMOPTI ONS SYSCAT V 2009-07-17-22.09.11.488001
FUNCMAPPINGS SYSCAT V 2009-07-17-22.09.11.489001
FUNCPARMS SYSCAT V 2009-07-17-22.09.11.490003
FUNCTIONS SYSCAT V 2009-07-17-22.09.11.494000
HIERARCHIES SYSCAT V 2009-07-17-22.09.11.497001
INDEXAUTH SYSCAT V 2009-07-17-22.09.11.498002
INDEXCOLUSE SYSCAT V 2009-07-17-22.09.11.499003
INDEXDEP SYSCAT V 2009-07-17-22.09.11.500003
INDEXES SYSCAT V 2009-07-17-22.09.11.501003
INDEXEXPLOITRUL ES SYSCAT V 2009-07-17-22.09.11.505001
INDEXEXTENSIOND EP SYSCAT V 2009-07-17-22.09.11.527002
INDEXEXTENSIONM ETHODS SYSCAT V 2009-07-17-22.09.11.534002
INDEXEXTENSIONP ARMS SYSCAT V 2009-07-17-22.09.11.536001
INDEXEXTENSIONS SYSCAT V 2009-07-17-22.09.11.517001
INDEXOPTIONS SYSCAT V 2009-07-17-22.09.11.537002
INDEXXMLPATTERN S SYSCAT V 2009-07-17-22.09.11.932000
KEYCOLUSE SYSCAT V 2009-07-17-22.09.11.538003
LIBRARIES SYSCAT V 2009-07-17-22.09.11.577001
LIBRARYAUTH SYSCAT V 2009-07-17-22.09.11.540000
LIBRARYBINDFILE S SYSCAT V 2009-07-17-22.09.11.578003
LIBRARYVERSIONS SYSCAT V 2009-07-17-22.09.11.580001
NAMEMAPPINGS SYSCAT V 2009-07-17-22.09.11.581003
NICKNAMES SYSCAT V 2009-07-17-22.09.11.582003
NODEGROUPDEF SYSCAT V 2009-07-17-22.09.11.585001
NODEGROUPS SYSCAT V 2009-07-17-22.09.11.598001
PACKAGEAUTH SYSCAT V 2009-07-17-22.09.11.599003
PACKAGEDEP SYSCAT V 2009-07-17-22.09.11.600003
PACKAGES SYSCAT V 2009-07-17-22.09.11.602001
PARTITIONMAPS SYSCAT V 2009-07-17-22.09.11.604002
PASSTHRUAUTH SYSCAT V 2009-07-17-22.09.11.606001
PREDICATESPECS SYSCAT V 2009-07-17-22.09.11.607002
PROCEDURES SYSCAT V 2009-07-17-22.09.11.609000
PROCPARMS SYSCAT V 2009-07-17-22.09.11.622003
REFERENCES SYSCAT V 2009-07-17-22.09.11.624001
ROUTINEAUTH SYSCAT V 2009-07-17-22.09.11.625001
ROUTINEDEP SYSCAT V 2009-07-17-22.09.11.634002
ROUTINEOPTIONS SYSCAT V 2009-07-17-22.09.11.613003
ROUTINEPARMOPTI ONS SYSCAT V 2009-07-17-22.09.11.620003
ROUTINEPARMS SYSCAT V 2009-07-17-22.09.11.632002
ROUTINES SYSCAT V 2009-07-17-22.09.11.626003
ROUTINESFEDERAT ED SYSCAT V 2009-07-17-22.09.11.630002
SCHEMAAUTH SYSCAT V 2009-07-17-22.09.11.635001
SCHEMATA SYSCAT V 2009-07-17-22.09.11.636003
SECURITYLABELAC CESS SYSCAT V 2009-07-17-22.09.11.637002
SECURITYLABELCO MPONENTELEMENTS SYSCAT V 2009-07-17-22.09.11.638003
SECURITYLABELCO MPONENTS SYSCAT V 2009-07-17-22.09.11.640001
SECURITYLABELS SYSCAT V 2009-07-17-22.09.11.665003
SECURITYPOLICIE S SYSCAT V 2009-07-17-22.09.11.704001
SECURITYPOLICYC OMPONENTRULES SYSCAT V 2009-07-17-22.09.11.701001
SECURITYPOLICYE XEMPTIONS SYSCAT V 2009-07-17-22.09.11.702003
SEQUENCEAUTH SYSCAT V 2009-07-17-22.09.11.757001
SEQUENCES SYSCAT V 2009-07-17-22.09.11.755000
SERVEROPTIONS SYSCAT V 2009-07-17-22.09.11.761001
SERVERS SYSCAT V 2009-07-17-22.09.11.778002
STATEMENTS SYSCAT V 2009-07-17-22.09.11.805003
SURROGATEAUTHID S SYSCAT V 2009-07-17-22.09.11.807001
TABAUTH SYSCAT V 2009-07-17-22.09.11.808003
TABCONST SYSCAT V 2009-07-17-22.09.11.810002
TABDEP SYSCAT V 2009-07-17-22.09.11.816000
TABDETACHEDDEP SYSCAT V 2009-07-17-22.09.11.817001
TABLES SYSCAT V 2009-07-17-22.09.11.818002
TABLESPACES SYSCAT V 2009-07-17-22.09.11.822001
TABOPTIONS SYSCAT V 2009-07-17-22.09.11.823003
TBSPACEAUTH SYSCAT V 2009-07-17-22.09.11.824003
TRANSFORMS SYSCAT V 2009-07-17-22.09.11.826002
TRIGDEP SYSCAT V 2009-07-17-22.09.11.828001
TRIGGERS SYSCAT V 2009-07-17-22.09.11.829001
TYPEMAPPINGS SYSCAT V 2009-07-17-22.09.11.842003
USEROPTIONS SYSCAT V 2009-07-17-22.09.11.844003
VIEWDEP SYSCAT V 2009-07-17-22.09.11.846001
VIEWS SYSCAT V 2009-07-17-22.09.11.847001
WRAPOPTIONS SYSCAT V 2009-07-17-22.09.11.848003
WRAPPERS SYSCAT V 2009-07-17-22.09.11.851002
XDBMAPGRAPHS SYSCAT V 2009-07-17-22.09.11.933003
XDBMAPSHREDTREE S SYSCAT V 2009-07-17-22.09.11.935002
XSROBJECTAUTH SYSCAT V 2009-07-17-22.09.11.859000
XSROBJECTCOMPON ENTS SYSCAT V 2009-07-17-22.09.11.856003
XSROBJECTDEP SYSCAT V 2009-07-17-22.09.11.937000
XSROBJECTHIERAR CHIES SYSCAT V 2009-07-17-22.09.11.860001
XSROBJECTS SYSCAT V 2009-07-17-22.09.11.853000

110 record(s) selected.


C:\Users\vijay> db2 select count(*) from syscat.columns

1
-----------
4250

1 record(s) selected.


C:\Users\vijay> db2 create table db2admin.column s like syscat.columns
DB20000I The SQL command completed successfully.

C:\Users\vijay> db2 describe table db2admin.column s

Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
TABSCHEMA SYSIBM VARCHAR 128 0 No
TABNAME SYSIBM VARCHAR 128 0 No
COLNAME SYSIBM VARCHAR 128 0 No
COLNO SYSIBM SMALLINT 2 0 No
TYPESCHEMA SYSIBM VARCHAR 128 0 No
TYPENAME SYSIBM VARCHAR 128 0 No
LENGTH SYSIBM INTEGER 4 0 No
SCALE SYSIBM SMALLINT 2 0 No
DEFAULT SYSIBM VARCHAR 254 0 Yes
NULLS SYSIBM CHARACTER 1 0 No
CODEPAGE SYSIBM SMALLINT 2 0 No
LOGGED SYSIBM CHARACTER 1 0 No
COMPACT SYSIBM CHARACTER 1 0 No
COLCARD SYSIBM BIGINT 8 0 No
HIGH2KEY SYSIBM VARCHAR 254 0 Yes
LOW2KEY SYSIBM VARCHAR 254 0 Yes
AVGCOLLEN SYSIBM INTEGER 4 0 No
KEYSEQ SYSIBM SMALLINT 2 0 Yes
PARTKEYSEQ SYSIBM SMALLINT 2 0 Yes
NQUANTILES SYSIBM SMALLINT 2 0 No
NMOSTFREQ SYSIBM SMALLINT 2 0 No
NUMNULLS SYSIBM BIGINT 8 0 No
TARGET_TYPESCHE MA SYSIBM VARCHAR 128 0 Yes
TARGET_TYPENAME SYSIBM VARCHAR 128 0 Yes
SCOPE_TABSCHEMA SYSIBM VARCHAR 128 0 Yes
SCOPE_TABNAME SYSIBM VARCHAR 128 0 Yes
SOURCE_TABSCHEM A SYSIBM VARCHAR 128 0 Yes
SOURCE_TABNAME SYSIBM VARCHAR 128 0 Yes
DL_FEATURES SYSIBM CHARACTER 10 0 Yes
SPECIAL_PROPS SYSIBM CHARACTER 8 0 Yes
HIDDEN SYSIBM CHARACTER 1 0 No
INLINE_LENGTH SYSIBM INTEGER 4 0 No
IDENTITY SYSIBM CHARACTER 1 0 No
GENERATED SYSIBM CHARACTER 1 0 No
TEXT SYSIBM CLOB 2097154 0 Yes
COMPRESS SYSIBM CHARACTER 1 0 No
AVGDISTINCTPERP AGE SYSIBM DOUBLE 8 0 Yes
PAGEVARIANCERAT IO SYSIBM DOUBLE 8 0 Yes
SUB_COUNT SYSIBM SMALLINT 2 0 No
SUB_DELIM_LENGT H SYSIBM SMALLINT 2 0 No
IMPLICITVALUE SYSIBM VARCHAR 254 0 Yes
SECLABELNAME SYSIBM VARCHAR 128 0 Yes
REMARKS SYSIBM VARCHAR 254 0 Yes

43 record(s) selected.


C:\Users\vijay> db2 select count(*) from syscat.columns

1
-----------
4293

1 record(s) selected.


C:\Users\vijay> db2 insert into db2admin.column s select * from syscat.columns fetch first 100 rows only
DB20000I The SQL command completed successfully.

C:\Users\vijay> db2 select count(*) from db2admin.column s

1
-----------
100

1 record(s) selected.

C:\Users\vijay> db2 insert into db2admin.column s select * from syscat.columns fetch first 1000 rows only
DB20000I The SQL command completed successfully.

C:\Users\vijay> db2 select count(*) from db2admin.column s

1
-----------
1100

1 record(s) selected.
Aug 21 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3032
by: Jason | last post by:
The best way to explain this is by example. I have a source table with many columns. Source SYMBOL EXCHANGE_NAME CUSIP TYPE ISSUE_NAME
2
21824
by: Jenny | last post by:
Hi! I wonder how to use conditions in the inserted table(in a insert/update) trigger? The inserted table contain all the rows that have been updated or inserted (for an update/insert trigger), but out of all these rows in inserted table, I only want the rows where a particular field have been updated, for example if idkey have been updated...
7
10228
by: Alex Vorobiev | last post by:
hi there, i am using sql server 7. below is the stored procedure that is giving me grief. its purpose it two-fold, depending on how it is called: either to return a pageset (based on page number and page size), or to return IDs of previous and next records (based on current record id). the problem is, that the order in which records are...
3
5766
by: Magnus Byne | last post by:
Hi, I have a problem using serializable transactions. In one transaction I select a single specific row from a table using a where clause (this causes it to acquire and hold a range lock). In another transaction I attempt to insert a new row into the table (which does not match the first transactions where clause), but it is blocked by the...
16
16995
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then...
16
3861
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the table, or perhaps bytes, being updated where the engine just decides, screw it, i'll just make a new one. surfed this group and google, but...
2
3186
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request : INSERT INTO temp_tab VALUES (1,2,3)
3
2152
by: Mike Charney | last post by:
I have a two part question: First I want to insert data into a table and I am using the following command: INSERT INTO tblmain SELECT field1, field2, etc... FROM tblimport WHERE ?????? The where clause is the part I am having trouble with. I want to only insert
6
3712
by: lenygold via DBMonster.com | last post by:
Hi everybody: What is the best way to I have 10 tables with similar INSERT requiremnts. INSERT INTO ACSB.VAATAFAE WITH AA(AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP) AS ( SELECT AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP FROM VAATAFAA WHERE AB_TP_ACNT_STAT_CD <0),
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.