- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to insert multiple rows in a table using a single INSERT command in program?
If we want to insert a multiple rows in a DB2 table using a single INSERT command then we have to define the host variable array and move the row data we want to insert in that array. We need to define another variable in the working storage section with configuration S9(4) COMP which will hold the number of rows to be inserted. We can insert the multiple rows as below−
MOVE 50 TO MAX-ROWS EXEC SQL INSERT INTO ORDERS (ORDER_ID, ORDER_DATE) VALUES(:ORDER-ID, :ORDER-DATE) FOR :MAX-ROWS ROWS END-EXEC
The ORDER-ID and ORDER-DATE are host variables which should be defined as an array and all the data should be populated in these variables before the INSERT statement.
- Related Articles
- Insert multiple rows in a single MySQL query
- How to insert multiple rows with single MySQL query?
- Insert multiple values in a temporary table with a single MySQL query?
- How to insert an array of values in a MySQL table with a single INSERT?
- How can we insert multiple tabs into a single JTabbedPane in Java?
- Fastest way to insert with multiple values in a single MySQL query?
- How to multiple insert or batch insert at a time in MySQL query?
- Insert multiple sets of values in a single statement with MySQL?
- How do I insert multiple values in a column with a single MySQL query?
- How to insert only a single column into a MySQL table with Java?
- How to insert rows into a ResultSet in JDBC?
- How to insert a single line break in HTML?
- MySQL INSERT INTO SELECT resulting in multiple rows inserted at once from another table
- How to insert into two tables using a single MySQL query?
- How to insert a DATALINK object into a table using JDBC?

Advertisements