Writing Data to an Array

From InterBase

Go Up to Accessing Array Data


isc_array_put_slice2() is called to write data to an array or array slice. Use it to:

  • Include a new array in a row to be inserted into a table.
  • Replace the current contents of an array column of a row with a new array.
  • Update the array referenced by an array column of a row by modifying the array data or a slice of the data.

The entry in an array column of a row does not actually contain array data. Rather, it has an array ID referring to the data, which is stored elsewhere. So, to set or modify an array column, you need to set or change the array ID stored in it. If an array column contains an array ID, and you modify the column to refer to a different array (or to contain NULL), the array referenced by the previously stored array ID will be deleted during the next garbage collection.

The following steps are required to insert, replace, or update array data:

  1. Prepare an array descriptor with information describing the array (or slice) to be written to.
  2. Prepare an array buffer with the data to be written.
  3. Prepare an appropriate DSQL statement. This will be an INSERT statement if you are inserting a new row into a table, or an UPDATE statement for modifying an existing row.
  4. Call ­isc_array_put_slice2() to create a new array (possibly copying an existing one), and to write the data from the array buffer into the array or array slice.
  5. Associate the new array with an array column of the table row being modified or inserted by executing the UPDATE or INSERT statement. This sets the array column to contain the array ID of the new array.

Topics

Advance To: