Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Inserting multiple rows using single INSERT statement?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
J.P.R.Kumar

New User


Joined: 02 Apr 2008
Posts: 11
Location: Chennai

PostPosted: Thu Jun 19, 2008 12:17 pm    Post subject: Inserting multiple rows using single INSERT statement?
Reply with quote

Hi all,

can we insert multiple rows using single insert statement, the code is as follows, but this is not working, can some one help .

insert into employ
(001,'phani','l&t infotech chennai'),
(002,'mani','l&t infotech chennai'),
(003,'ani','l&t infotech chennai');
Back to top
View user's profile Send private message

ascelepius

New User


Joined: 16 Jun 2008
Posts: 35
Location: bangalore

PostPosted: Thu Jun 19, 2008 12:23 pm    Post subject: Reply to: Inserting multiple rows using single INSERT state
Reply with quote

No you cannot, DB2 manuals say,

Quote:

There are three forms of this statement:
- The INSERT via VALUES form is used to insert a single row into the table or view using the values provided or referenced.
- The INSERT via SELECT form is used to insert one or more rows into the table or view using values from other tables, or views, or both.
- The INSERT via FOR n ROWS form is used to insert multiple rows into the table or view using values provided from host-variable arrays.


regards,
asci(i)
Back to top
View user's profile Send private message
J.P.R.Kumar

New User


Joined: 02 Apr 2008
Posts: 11
Location: Chennai

PostPosted: Thu Jun 19, 2008 2:35 pm    Post subject: DB2 manuals say its possible
Reply with quote

hi ascelepius,

The db2 manual only says that there is a provision for the insertion of multiple rows using single insert statement (the code which i pasted is a ex.). but when i tried its not working.
Back to top
View user's profile Send private message
ascelepius

New User


Joined: 16 Jun 2008
Posts: 35
Location: bangalore

PostPosted: Thu Jun 19, 2008 2:55 pm    Post subject: Reply to: Inserting multiple rows using single INSERT state
Reply with quote

Well, if you read the manual carefully you will note that this can be achieved only with host variables/arrays...

regards,
asci(i)
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 19, 2008 3:34 pm    Post subject:
Reply with quote

Hi Kumar,

Here's a link which will help you on this .

http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0004231.htm

Kindly check your DB2 version for the multi-row insert query.

Code:

INSERT INTO DEPARTMENT (DEPTNO, DEPTNAME, ADMRDEPT)
VALUES ('B11', 'PURCHASING', 'B01'),
            ('E41', 'DATABASE ADMINISTRATION', 'E01')


Quote:
Well, if you read the manual carefully


And "ascelepius" I think this applies to you.
icon_rolleyes.gif
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 19, 2008 3:35 pm    Post subject:
Reply with quote

Igonre previous link use the below one .

http://publib.boulder.ibm.com/infocenter/db2luw/v8/topic/com.ibm.db2.udb.doc/admin/r0000970.htm
Back to top
View user's profile Send private message
ascelepius

New User


Joined: 16 Jun 2008
Posts: 35
Location: bangalore

PostPosted: Thu Jun 19, 2008 3:51 pm    Post subject: Reply to: Inserting multiple rows using single INSERT state
Reply with quote

@abhishek

Oops! I refer to the DB2 manuals for ZO/S( i didnot google).

You are right. I overlooked the fact that queries related to DB2 UDB on non-mainframe could appear here.

For DB2 V8 on Z O/S, this is not possible

regards,
asci(i)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us