New Error Conditions
Go Up to Isc_dsql_batch_execute_immed
The following table shows the error codes that are returned by the isc_dsql_batch_execute_immed
function.
Error code | Description |
---|---|
|
Returned when the total length of all SQL statement strings (including NULL characters) exceeds 2 GB. |
|
Returned when one of the SQL statements is found to be a Note that all statements prior to the The rows_affected argument for the The changes made by statements prior to the |
The following examples explain how to execute two statements in a batch update: One INSERT
statement, and one DELETE
statement. Notice the individual statements do not need to be terminated with a semicolon.
The number of rows affected by each statement is stored in the array called rows
. The array must contain one element for each SQL statement executed in the batch update.
Example 1: Preparing Buffers for a Batch Update
char *sql1 = “INSERT INTO DEPARTMENT (dept_no, department, head_dept) values (‘117’, ‘Field Office: Hong Kong’, ‘110’)”; char *sql2 = “DELETE FROM DEPARTMENT WHERE dept_no = ‘117’”; char *sql_statements[2]; ISC_ULONG rows[2] = {0, 0}; sql_statements[0] = sql1; sql_statements[1] = sql2;
Next example shows how to execute the batch update.
Example 1: Executing a Batch Update
/* Start a transaction */ if(isc_start_transaction(status, &trans, 1, &DB, 0, NULL)) ERREXIT(status,1); /* Submit the batch update */ if(isc_dsql_batch_execute_immed(status, &DB, &trans, 3, 2, sql_statements, &rows)) ERREXIT(status, 1); /* Print results and end the transaction */ printf(“Returned rows from the batch command: %d, %d”, rows[0], rows[1]); printf(“Done with isc_dsql_execute_immed\n”); if(isc_commit_transaction(status, &trans)) ERREXIT(status, 1);