Producing Data Using fetch_block

Use the fetch_block API method to produce data.

  1. Set max_rows to the number of rows the producer-allocated row block structure can hold.
  2. On the first fetch call, allocate a row block structure that can hold max_rows.
  3. Set num_rows to a value based on the number of rows produced in the fetch call.
  4. For each row produced, set the row_status flag of a_v4_extfn_row to 1 (available) or 0 (not available). The default value is 1.
  5. For each column (a_v4_extfn_column_data) in the row set:
    Option Description
    null_value Indicates the value is used to indicate NULL
    null_mask Identifies the bits that represent the NULL value.
    is_null If the value is NULL, set is_null to a value such that (*(cd->is_null) & cd->null_mask) == cd->null_value ).
    data Set this pointer to the area in the producer's memory containing the data to be returned.
    piece_len The actual length of data being returned. For fixed-length data types, this cannot exceed max_piece_len. This value defaults to max_piece_len for fixed data types.
  6. Return 1 from fetch_into to indicate rows were produced, and return 0 to indicate otherwise. On the last fetch call, deallocate any memory that is allocated for the row block structure.