Populating the Array Descriptor

From InterBase

Go Up to Reading Data from an Array


To prepare an array descriptor that describes the array or array slice to be read, follow these steps:

  1. Create the array descriptor:
    ISC_ARRAY_DESC_V2 desc;
    
  2. Fill in the descriptor with information regarding the array column from which data will be read. Do this either by calling one of the functions isc_array_lookup_bounds2(), isc_array_lookup_desc2(), or ­isc_array_set_desc2(), or by directly filling in the descriptor. For information on the contents of array descriptors and the use of these functions, see Array Descriptors. Ensure the descriptor boundaries are set to those of the slice to be read. If you want to retrieve all the array data (that is, not just a smaller slice), set the boundaries to the full boundaries as initially declared for the array column. This is guaranteed to be the case if you fill in the descriptor by calling ­isc_array_lookup_bounds2(), as in:
    ISC_ARRAY_DESC_V2 desc;
    isc_array_lookup_bounds2( status_vector, &db_handle, &trans,
    "PROJ_DEPT_BUDGET", /* table name */
    "QUART_HEAD_CNT", /* array column name */
    &desc);
    

    Suppose the array column, QUART_HEAD_CNT, is a one-dimensional array consisting of four elements, and was declared to have a lower subscript bound of 1 and an upper bound of 4 when it was created. Then after the above call to­ isc_array_lookup_bounds2(), the array descriptor fields for the boundaries contain the following information:

    desc.array_desc_bounds[0].array_bound_lower == 1
    desc.array_desc_bounds[0].array_bound_upper == 4
    

    If you want to read just a slice of the array, then modify the upper and/or lower bounds appropriately. For example, if you just want to read the first two elements of the array, then modify the upper bound to the value 2, as in:

    desc.array_desc_bounds[0].array_bound_upper = 2
    

Advance To: