Entering content frame

 Arrays as Host Variables 

Host variables can be arrays. In an array statement they cause an SQL statement to be executed more than once.

In multi-dimensional arrays, the last dimension is run first.

EXEC SQL BEGIN DECLARE SECTION;

float p[3][2];

EXEC SQL END DECLARE SECTION;

EXEC SQL CREATE TABLE KOORD (x float, y float);

p[0][0] = 0.0;

p[0][1] = 0.1;

p[1][0] = 1.0;

p[1][1] = 1.1;

p[2][0] = 2.0;

p[2][1] = 2.1;

EXEC SQL INSERT INTO KOORD VALUES (:p);

/* insert generates following content */

/*      x  |  y                                  */
/*     ---------                                 */
/*     0.0 | 0.1                                 */
/*     1.0 | 1.1                                 */
/*     2.0 | 2.2                                 */

Also specify the corresponding indicator variable as an array, with the same length and dimension.

You can use a simplified notation for array variables in SQL statements.

 

Leaving content frame