The first step, when using row-wise array insert, is to create a structure that contains two elements for each parameter. The first element for each parameter holds the length/indicator buffer, and the second element holds the value itself. Once the structure is defined the application must allocate an array of these structures. The number of rows in the array corresponds to the number of values that will be used for each parameter.
struct { SQLINTEGER La; SQLINTEGER A; /* Information for parameter A */ SQLINTEGER Lb; SQLCHAR B[4]; /* Information for parameter B */ SQLINTEGER Lc; SQLCHAR C[11]; /* Information for parameter C */ } R[n];Figure 11 shows the structure R with three parameters, in an array of n rows. The array can then be populated with the appropriate data.
Once the array is created and populated the application must indicate that row-wise binding is going to be used. It does this by setting the statement attribute SQL_ATTR_PARAM_BIND_TYPE to the length of the structure created. The statement attribute SQL_ATTR_PARAMSET_SIZE must also be set to the number of rows in the array.
Each parameter can now be bound to the appropriate two elements of the structure (in the first row of the array) using SQLBindParameter().
/* Parameter A */ rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 5, 0, &R[0].A, 0, &R.La); /* Parameter B */ rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 10, 0, R[0].B, 10, &R.Lb); /* Parameter C */ rc = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 3, 0, R[0].C, 3, &R.Lc);
At this point the application can call SQLExecute() once and all of the updates are sent to the database.
Figure 11. Row-Wise Array Insert
![]() |
See "Retrieving Diagnostic Information" for information on errors that can be accessed by the application.