Here is an SQL query that to INSERT array of values into a DB2 table.
In DB2 or any RDBMS, there are a variety of rules you need to follow before inserts a row into a Table. In my previous post DB2: 4 TOP QUESTIONS ON SQL INSERT VALUES, I have explained these.
SQL Query to Insert Array of Values into DB2 Table
Below is INSERT SQL. Here you need to supply Array of VALUES.
EXEC SQL
INSERT INTO srinmf_test
(ACT_NO, ACT_KWD, ACT_DESC)
VALUES (:HV1, :HV2, :HV3)
FOR :NUM-ROWS ROWS
END-EXEC.
Explanation:
- In the above query, the table name is srinimf_test.
- The ACT_NO, ACT_KWD, ACT_DESC are the column names in that table.
:HV1, :HV2 and :HV3 are host variables.
- The num_rows in For clause says, the number of rows to insert.
- This way of writing SQL Query is called array inserting in DB2.
Related Posts
Get new content delivered directly to your inbox.